Connecting to DB2 from my Scala-app on top of Jetty work fine (1-2 seconds) when I run the app in console,by starting jetty manually "java -jar start.jar". However, when I start Jetty as a service, the connection takes 30-60 seconds to establish.
This is something I have spent few days trying to solve.
First I thought it is something to do with the iSeries Access ODBC Driver, which is used. I have another app written with Javascript, running on top of Node.js, which seems to work ok with this connection. I also played with most of the options this driver provides, but they didn't seem to help. Then I thought the problem has to be with th JDBC, and I tried to use com.ibm.db2.jcc.DB2Jcc, but this didn't seem to fix the problem.
I put a logger to inspect what happens with the connection, but this didn't bring any extra help. Both connections seems similar, except when run as service it takes at least ten times longer to establish connection.
I thought that the issue could be if DB2-driver tries to authenticate against Activer directory, which is in use, so I created a local user "foobar". I set the iSeries to use this user ID as default. This didn't help either. I also tried to run the service with my username, which didn't help.
I'm currently out of ideas. Is it possible that starting Jetty manually on console loads different settings than by starting it as a service (net start app).
Any help would be much appreciated!
Stack:
DB2 on external server. No access to configure.
iSeries Access ODBC Driver, version 9.00.00.00
Scala app, Scalatra framework
Jetty 8.1.3 container
NSSM to wrap Jetty as a service. Uses java.exe (copied to app-directory) and the options are "-jar start.jar".
Windows 2003 server
Connection is setup simply with DriverManager:
private def foobarDbConnection: Connection = {
Class.forName(Settings.foobarDbDriver)
DriverManager.getConnection(Settings.foobarDatabase,
Settings.foobarUsername,
Settings.foobarPassword)
}
Settings:
def foobarDbDriver = "com.ibm.db2.jcc.DB2Jcc"
def foobarDatabase = "jdbc:odbc:FOOBAR"
def foobarUsername = "foo"
def foobarPassword = "bar"
Here's log from connection:
13.2.2013 13:45:54 com.foo.lib.DbConnectionFactory$JDBCLogWriter write
INFO: DriverManager.getConnection("jdbc:odbc:FOOBAR")
13.2.2013 13:45:54 com.foo.lib.DbConnectionFactory$JDBCLogWriter write
INFO: trying driver[className=com.ibm.db2.jcc.DB2Driver,com.ibm.db2.jcc.DB2Driver#f6e15e]
13.2.2013 13:45:54 com.foo.lib.DbConnectionFactory$JDBCLogWriter write
INFO: trying driver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver#e8fdc9]
13.2.2013 13:45:54 com.foo.lib.DbConnectionFactory$JDBCLogWriter write
INFO: *Driver.connect (jdbc:odbc:FOOBAR)
13.2.2013 13:45:54 com.foo.lib.DbConnectionFactory$JDBCLogWriter write
INFO: JDBC to ODBC Bridge: Checking security
13.2.2013 13:45:54 com.foo.lib.DbConnectionFactory$JDBCLogWriter write
INFO: No SecurityManager present, assuming trusted application/applet
13.2.2013 13:45:54 com.foo.lib.DbConnectionFactory$JDBCLogWriter write
INFO: Allocating Environment handle (SQLAllocEnv)
13.2.2013 13:45:54 com.foo.lib.DbConnectionFactory$JDBCLogWriter write
INFO: hEnv=92738208
13.2.2013 13:45:54 com.foo.lib.DbConnectionFactory$JDBCLogWriter write
INFO: Allocating Connection handle (SQLAllocConnect)
13.2.2013 13:45:54 com.foo.lib.DbConnectionFactory$JDBCLogWriter write
INFO: hDbc=92739360
13.2.2013 13:45:54 com.foo.lib.DbConnectionFactory$JDBCLogWriter write
INFO: Connecting (SQLDriverConnect), hDbc=92739360, szConnStrIn=DSN=FOOBAR;UID=foo;PWD=bar
After few days of tracing and using Wireshark I managed to solve this by adding a local user into Windows server. In this case the name of the local user didn't matter (didn't have to be same as the username used in the DB2-connection). If the local user belonged into Administrator -group, then the problem persisted, so I created the local user without this group. It sounds like only the users on domain, or on admin-group are checked by active directory.
Related
I would need to fully initialize my mosquitto 1.5.7 broker , to clean all messages stored in the broker memory, all messages counter....
How can I do it ?
The #SYS always get all stored information when I restart with :
systemctl restart mosquitto
data in #SYS
If I can initialize the broker,does clients will connect again automatically ? (using their "reconnect process ...")
Thank for your help,
It really isn't clear what you are actually asking here, but to clear all the data from a Mosquitto broker you need to shut it down, then delete the persistence file (the path to this file will be in the mosquitto config file normally found in /etc/mosquitto/mosquitto.conf)
Once you have deleted the persistence file restart the broker.
And yes, most clients will reconnect when the broker comes back up, but all their session data will have been lost so they will need to resubscribe to any topics they are interested in.
I am trying to get a connection string right, and using odbcad32.exe to test the connection.
The trouble is, I get Connection Established, regardless of what password I enter.
This seems pretty useless.
My .NET program fails with Data source name not found and no default driver specified even though odbcad32.exe has no problem getting the connection.
Data Source Name : Test_Blah
Description: Test_Blah
Host Name: blh-housing
Port Number: 5060
Database name: ih
User ID: administrator
Driver: Progress OpenEdge 10.2b Driver
Password: (space)
This is my connection string:
<add name="BlhConnection" connectionString="DSN=Test_Blah;UID=Administrator;PWD=' ' ;" />
Any ideas how I can get this working?
32 bit ODBC Drivers and connections based on those are only accessible by 32 bit clients.
You are not mentioning your OS - but when your client application is a 64 bit application the 32 bit ODBC driver won't work. I am not 100% sure - but I doubt that there is a 64 bit ODBC driver for OpenEdge in 10.2B. On OpenEdge 11 that's no problem.
I would start by verifying that you have the correct login credentials. Especially since you state that you get the same result no matter what you use.
The easiest way to verify the credentials is to login to the db server and open a "proenv" session. Using proenv ensures that all of the Progress environment is correctly set. If it is a Windows server "proenv" is in the Progress or OpenEdge program group, if the server is UNIX you can run "$DLC/bin/proenv" from the command line. Once you are running a proenv shell you can then use the "sqlexp" tool that Progress provides to verify your connection string and credentials. For example:
sqlexp -user userName -password passWord -db dbName -S portNum
I'm using MonetDB on a variety of platform (e.g. OS X and Linux Centos) with a shiny application.
It is difficult to disconnect the db all the times, so currently my approach is to terminate the shiny app without disconnecting the db.
This means that the shiny app before accessing the data tries to stop any "old" process with:
monetdb.server.stop(pid)
From the source of the command I understand that it basically kills the process associated to the pid provided (which means among other things that the user running the app must have access to the kill function).
This works OK some of the times, but sometimes when I try to start MonetDB again, I get
!FATAL: GDKlockHome: Database lock '.gdk_lock' denied
Warning in socketConnection(host = host, port = port, blocking = TRUE, open = "r+b", :
localhost:50000 cannot be opened
Error in socketConnection(host = host, port = port, blocking = TRUE, open = "r+b", :
cannot open the connection
Is there a way to avoid this error (without forcibly disconnecting the database all the time I use it in shiny)?
It can indeed take a couple of seconds for MonetDB to shut down. If a new process is started on the same dbfarm directory in the meantime, you will get the !FATAL: GDKlockHome: Database lock '.gdk_lock' denied error. I'm considering adding a wait parameter to monetdb.server.stop.
So in the meantime, waiting a bit before the server is started again is a good idea. Otherwise, consider using monetdbd to manage your MonetDB servers.
To connect from windows desktop to unix host, in order of administration on command line level, I like to use MobaXterm in it's free version
The connection is encrypted ssh, identification to Unix host is using user id, passwd.
There is an issue in I can't resolve:
In the "Session Settings" is a field "Execute Command".
This command there is supposed to be executed in the target host when login has been successful finished. The hosts I have to use are may be not the fastest - Or MobaXterm is too fast.
However, the command is issued in a to early stage, the host feels mortally offended, closes connection and throws me out.
It does not matter what the command is - even a sleep is not accepted.
How to tell MobaXterm to act a bit slower?
MobaXterm default behavior for executing a command is to close the session after execution.
To prevent that there is a setting near the "Execute command" field that states: "Do not exit after command ends". Just check that and it will fix the problem.
I have CoreFTP configured for localhost and the next code:
JSch.setLogger(new MyJschLogger()); //class for console output
Session session = jsch.getSession("user", "localhost", 21);
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.setPassword("password");
session.connect();
when program achieves connect(), two messages appear at console output:
INFO: Connecting to localhost port 21
INFO: Connection established
...and nothing more happens. After some minutes, connection is closed by foreign host exception appears.
Why?
Thanks for all!
Port 21 is the normal port for FTP. JSch is only an SSH client, with support for SFTP in the ChannelSFTP class. JSch knows nothing about FTP (and SFTP is unrelated to FTP, other than by name and that it allows similar things).
You need to setup your server to use the SSH protocol (usually on port 22, but you can use any port, as long as you use the same port on the client). See the documentation - I think you have to check the SSH check box.
Also, if your code is nothing more than what you posted, then nothing more than connecting will happen. To transfer files, you will need to open a ChannelSFTP, and issue the right commands (e.g. call one or more of the put/get methods).
I also faced the similar issue:
"ERROR 2016-04-27 15:05:16,489 [CollectionThreadPool-0] com.dell.supportassist.collector.cli.executor.SSHExecutor: com.jcraft.jsch.JSchException: connection is closed by foreign host"
In my case, channel was getting closed randomly. And when we are trying to re-connect the channel then it was not re-connecting and failing.
This was happening due to looping logic while connecting, so I tried to connect the session without channel by calling method connectWithoutOpenChannel instead of connectinternal(). This resolved my issue.