Windows XP SP3 TCP/IP No buffer space available - java

I need to create 1000 server sockets using Java. Somewhere between creating 600 and 700 sockets I'm getting this error:
05.04.2012 10:23:57 java.net.SocketException: No buffer space available (maximum connections reached?): listen at sun.nio.ch.ServerSocketChannelImpl.listen(Native Method) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:127) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:52) at channelserver.NIOAppServer.initSelector(NIOAppServer.java:40) at channelserver.NIOAppServer.(NIOAppServer.java:27) at channelserver.NIOServer.main(NIOServer.java:433) at channelserver.NIOServer.main(NIOServer.java:438)
After that my computer reboots.
I've tried to edit the registry setting MaxUserPort = 65534 and MaxFreeTcbs = 2000, but it didn't help.
What else can I do?
On http://serverfault.com someone told me that it may be related to JDBC, but I connect to DB only once. I use SQLite.
Any suggestions?

on Windows XP have a limit on half-open connection to broke this rule you need to patch your tcpip.sys driver (but it's illigable) or using modern OS like Windows Vista/7 they haven't those limits.

Just in case someone would face this problem too.
Finally it seemed to me that it's just WinXP's problem. I've tried the same code with more RAM - results were the same. But when I've tried it on Win7, everything worked fine even with 1200 sockets.
So, WinXP is just not suitable for such tasks.

Related

Extreme Slowness on Oracle Database Connection

I have a remote Linux server and I want to connect to an Oracle database which is in another server, using ojdbc7 lib
When I try to connect directly to the database from my Windows PC, using the same client and ojdbc7 lib, I have reasonable connection time.
Now, when I want to connect through my linux server, I get extreme slowness, just in the connection time. . Once connected, the execution is OK.
I have read about adding -Djava.security.egd=file:/dev/urandom like in this post, but nothing happened.
What could I do to fix this delay in setting up a connection from linux?
Close, but no cigar: it's "file:///dev/urandom", or one of the variations, see eg. https://anirban-m.blogspot.com/2014/03/jdbc-connection-reset-error-java.html
I noticed you are using version 12.1.0.1.
There was an Oracle bug where JDBC connections could take excessive times because the data being sent required the listener to perform a DNS lookup for each connection and that could apparently be very slow for some reason.
The bug was fixed in 12.2 and there is a back-ported fix (patch) for 12.1.0.2.
In the meantime, try getting your Linux admin to go through the process of tuning DNS lookups on that server. E.g., tune /etc/resolv.conf or enable the name service cache daemon. I'm not really expert in Linux administration so I can't help you. But based on the problem and the version you are using, that's where I'd look.

Mac OS X socket timeout

I have a weird problem in my OS X (Yosemite) machine: it seems that the network communication is slower than in other Windows machines of the same network, and the timeout seems shorter.
When I try to run our Java application, each transaction that is longer than 15s returns:
java.sql.SQLRecoverableException: IO Error: Operation timed out
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:876)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1153)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1275)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3620)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
at dome.dbComponents.dataModels.rowSet.StatementStatus.executeQuery(StatementStatus.java:71)
at com.dome.dCell.common.services.enterprise.types.Infusr.loadSQLFieldList(Infusr.java:976)
at dome.util.xml.converter.typeSQLManager.ThreadLoadSqlField.run(ThreadLoadSqlField.java:103)
Caused by: java.net.SocketException: Operation timed out
at java.net.SocketInputStream.socketRead0(Native Method)
INFO [28 Aug 2015 14:35:32,427] DomeEnterpriseService.loadAll(true) executed in 19724 ms
The timeout occurs when our Enterprise Service takes more than 15s to load all the enterprises from the database (it's not a bad query, there's simply a lot of information to store in memory).
This is not likely related directly to our software configuration being incompatible with OS X. I tried to run the same application in a Windows 7 VM (with VirtualBox) on the same iMac, and the problem remains.
I checked the connection with the database machine (a Linux server), and everything seems fine.
I've also tried different configurations in /etc/sysctl.conf (net.inet.tcp.msl) but it doesn't seem to make a big difference. Also, I don't find anything like the net.ipv4.tcp_syn_retries configuration of Linux, and maybe I'm googling the wrong keywords, but I don't find much about tweaking the timeout of OS X.
I don't recall having this problem before on this machine. I updated the JDK 1.7 to the last version (1.7.0_79), all the OS updates, nothing improves.
We tried with different machines (Linux & Windows, it's the only Mac), and no one is able to reproduce this.
Any ideas?

VisualVM Cannot connect to 178.xxx.xxx.xxx:xxxx using service:jmx:rmi///

I used visualvm last week on my notebook and it worked without any issues. When I wanted to use it yesterday I get the error: VisualVM Cannot connect to 178.xxx.xxx.xxx:xxxx using service:jmx:rmi///... once adding a jmx connection.
The odd thing here is that I have the same version of visualvm, java jdk, java security level, internet connection and windows 7 professional on the desktop computer where it still works.
firewall disabled (didn't work)
port forwarding (not needed as it works fine on the desktop computer with the same connection)
additional firewalls or anti virus software is not present
The notebook is a dell and a few days ago it got a major bios and dell util update, but I don't think this should fall into account in this matter.
Do you have any idea what else it could be, or what else I could do to track down the issue?
FYI I have another WIN7 home computer where it still works and a partner reported that he is getting the same issue for some time now on his desktop and notebook. I'm really at the end of my expertise :(
Seems like network environment issue. You may trace the other port first. (like 80 port)

mysql jdbc communication exception

I have a Java application which initially reads 3 lakhs of data from my MYSQL database.Then it calls an API using an ExecutorService with newFixedThreadPool size=20.
After getting the response from the API it is inserting the responses to my DB.It is working fine for first 2000 rows(nearby).After that I am getting an error like following.
SQLError-com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The
driver was unable to create a connection due to an inability to
establish the client portion of a socket.
This is usually caused by a limit on the number of sockets imposed by
the operating system. This limit is usually configurable.
For Unix-based platforms, see the manual page for the 'ulimit'
command. Kernel or system reconfiguration may also be required.
For Windows-based platforms, see Microsoft Knowledge Base Article
196271 (Q196271).
Anyone could help me to fix this issue?
I was able to fix this problem by increasing the # of sockets that can be opened in Windows:
From the Windows Start menu, run the regedit.exe application
In the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters directory, create a new DWORD value named MaxUserPort with a decimal value of 65,000 (the default is 5,000)
After closing the regedit application, restart your computer.
(See also Increasing the number of Windows sockets or ports, Maximum Socket Connections)
A note of caution: When an application is using more than 5,000 socket connections, that may be an indication that system resources are not being used in a sustainable way. It would be good to investigate the root cause for why so many sockets are being opened simultaneously.

Java getConnection to Oracle DB on UNIX crashed or takes much longer than on Windows

I actual have a big problem! I open a connection to a oracle database with "DriverManager.getConnection(url, properties)".
On UNIX machines (currently on a VM), the problem occurs that 99% of the time it needs minutes till the function return a connection. I increased the connection timout of oracle so that I don't get a SQLException, but it needs up to 3 Minutes to get a connection. On my windows machine the connection is returned in under 1 second.
telnet to server + port works, ping is sucessfully, traceroute looks good. I also tried from several VMs or on different databases on different physical machines.
I run the actual JDBC Driver "ojdbc6-11.2.0.2.0.jar".
Does anyone have a good idea?
After a long time we figured out the problem. The Oracle JDBC driver blocked at the point where a unique id was read. After setting the VM Argument
-Djava.security.egd=file:/dev/urandom
we could gurantee to always receive a uniqueid in an adequate time. The default /dev/random unfortunately just generates a uniqueid if the machine has enough entropy, which is often missing on virtual machines.
Maybe this helps some of you folks one day.
It's a little bit strange but it could be a REVERSE DNS problem.
If you Oracle server is on unix, try the following:
$ host IP_ADDRESS_OF_WIN_MACHINE
$ host IP_ADDRESS_OF_LINUX_MACHINE
See if there is something different on the two name resolutions. If there is, then it might be the case that trying to do a reverse DNS lookup on the LINUX IP is taking too long.
It's happened to me.

Categories