I have created a service that opens a lots of remote resources; for a lot, i mean over 200k / day, but i think that less than 1000 connections are opened at the same time. After i connect to the remote resource, i open an input stream to get the file content.
Sometimes i get the following exception
java.net.BindException: Address already in use: connect
at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.followRedirect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sitodove.varie.ExternalLinksChecker.getWebPage(ExternalLinksChecker.java:121)
at sitodove.varie.ExternalLinksChecker.run(ExternalLinksChecker.java:37)
This service starts correctly, opening just a few ports for limited needs because it needs to offer some services. While it is running, i get the above exception, what may be the cause?
A port is already being used and you try to bind it again. Check in your application if your are not trying to use a port twice.
Probably, you're trying to open a port that is already open.
open the terminal an type telnet to see if that port is already open. ie.
telnet localhost 9889
Trying ::1...
telnet: connect to address ::1: Connection refused
if this command returns Connection refused, that means the port is free.
Related
I am using SoapUI 5.2. When I Start SoapUI, it works fine but after a while, it goes offline and Startup Page keeps on saying 'The page could not be loaded'. The only time it get backs to work is after restarting the PC. I checked the log and found following stacktrace. I've tried forcing IPV4 as per few suggestion. But no luck.
INFO:I/O exception (java.net.SocketException) caught when connecting to the target host: Permission denied: connect
DEBUG:Permission denied: connect
java.net.SocketException: Permission denied: connect
at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:123)
at com.eviware.soapui.impl.wsdl.support.http.SoapUIMultiThreadedHttpConnectionManager$SoapUIClientConnectionOperator.openConnection(SoapUIMultiThreadedHttpConnectionManager.java:262)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:561)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport$Helper.execute(HttpClientSupport.java:233)
at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport.execute(HttpClientSupport.java:323)
at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.submitRequest(HttpClientRequestTransport.java:290)
at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.sendRequest(HttpClientRequestTransport.java:220)
at com.eviware.soapui.impl.wsdl.WsdlSubmit.run(WsdlSubmit.java:119)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Check active ports using netstat -o in command prompt, verify the PID(Process Id ) from TaskManager>>Processes tabs for Netbeans and Sopaui if it conflicts change the port of either one.
I have created a fresh Liferay 6.2 CE GA4 using pre-downloaded SDK/Tomcat/LR Source. I have created server in eclipse and when I try to create portlet for the first time it try to download "gradle-2.2.1-bin.zip" from the internet.
I have downloaded same from gradle from "https://downloads.gradle.org/distributions/gradle-2.2.1-bin.zip" and placed it inside "liferay-plugins-sdk-6.2\tools\gradle\gradle\wrapper".
Still it shows the same error as below:
`Downloading https://services.gradle.org/distributions/gradle-2.2.1-bin.zip
Exception in thread "main" java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at org.gradle.wrapper.Download.downloadInternal(Download.java:56)
at org.gradle.wrapper.Download.download(Download.java:42)
at org.gradle.wrapper.Install$1.call(Install.java:57)
at org.gradle.wrapper.Install$1.call(Install.java:44)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:44)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:56)
`
Am I placing that zip on wrong directory or missing something else ?
From the error message, I'd say: Yes, it seems you put the file into the wrong directory. Which one is the correct one? I don't know. It'd be easiest to do your first build while connected to the internet. The download will just happen once (also, there might be more dependencies that need to be downloaded) and you can do your builds offline after that.
To resolve your problem, you need to:
1) Delete content on:
D:\Profiles\XXX.gradle\wrapper\dists\gradle-2.2.1-bin\88n1whbyjvxg3s40jzz5ur27
2) Download manually:
https://services.gradle.org/distributions/gradle-2.2.1-bin.zip
3) Put gradle-2.2.1-bin.zip on:
D:\Profiles\XXX.gradle\wrapper\dists\gradle-2.2.1-bin\88n1whbyjvxg3s40jzz5ur27
I am trying to execute a crawler program from my office. A very basic one which is available in internet and which works fine in my home PC. However while I am trying to run the same program in my office PC i am getting connect timed out error. I thought it was proxy problem and tried accessing some site from eclipse internal browser and it worked fine also.
Document doc = Jsoup.connect("http://flipkart.com/").timeout(0).get();
Please find below my stack trace
Exception in thread "main" java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:449)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:434)
at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:181)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:170)
at org.syntel.crawler.Crawler.processPage(Crawler.java:44)
at org.syntel.crawler.Crawler.main(Crawler.java:20)
How can I fix this problem?
#alkis made the suggestion:
Try setting a user agent. ff you are using a proxy check this other question:
How to add proxy support to Jsoup (HTML parser)?
Try using:
System.out.println("Testing JSOUP\n--------------");
Proxy proxy = new Proxy( //
Proxy.Type.HTTP, //
InetSocketAddress.createUnresolved("www.yourPROXY.com", 80) //
);
Document doc = Jsoup.connect("http://en.wikipedia.org/").proxy(proxy).get();
Elements newsHeadlines = doc.select("#mp-itn b a");
System.out.println(newsHeadlines.html());
how are you?
Well, the problem is that we are using Axis1 to consume a wsdl based webservice which works fine when the URL where the WSDL is located uses plain old HTTP connection, but when it uses a SSL secured conection it brings a ConnectionException when Axis1 tries to download the WSDL document content.
Even reading comments on XMLUtils.class the Axis developers aren't even sure if it will work with HTTPS as it reads on line 810.
Is there any way to solve this? Whe tried to install the certificates on the computer, on ...jre7/lib/security/cacerts and tried to trust all certificates but the problem persists...
Thanks in advance.
Edit:
You can reproduce the Exception with this code:
InputSource source = new InputSource(urlWSDL);
DocumentBuilder db = DocumentBuilderFactoryImpl.newInstance().newDocumentBuilder();
Document doc = (Document) db.parse(source);
The Exception is:
java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
The problem was the Company Proxy, so I've appended:
System.setProperty("https.proxySet", "true");
System.setProperty("https.proxyHost", this.getConfiguracionProxy().getUrlProxy());
System.setProperty("https.proxyPort", this.getConfiguracionProxy().getPuertoProxy());
To:
System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", this.getConfiguracionProxy().getUrlProxy());
System.setProperty("http.proxyPort", this.getConfiguracionProxy().getPuertoProxy());
I've found the solution looking at Wireshark. When I was getting the file on SoapUI or on a web browser, the IP was other than the IP used by our application (the true IP). Then I realized that I was behind a proxy.
I've never used Wireshark... I've learned a lot, which is a good thing.
This sets as a System property the stored proxy configuration.
Thanks everybody.
I have a mysql database created on a raspberry pi, I want to access it through a java application running on a laptop in the same local network.
I tried connecting that same application with another database on another computer on the network and it worked. I don't know why it isn't working with the RPI.
i connect through the following command:
String URL = "jdbc:mysql://192.168.11.157/DB_name";
try {
connection = DriverManager.getConnection(URL, USER, PASSWORD);
} catch (SQLException e) {
e.printStackTrace();
}
However, an exception is thrown and ERROR: Unable to Connect to Database. is printed to the console.
Edit:
Knowing that:
* I can access the database through a local app running on the same raspberry pi (i used #local).
* Can Successfully ping & SSH with the raspberry pi, even run the program mentioned in the previous point through the SSH and it works fine.
The stack trace:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1121)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:358)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2489)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2526)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2311)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:347)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.climacon.jdbc.db.JDBCMySQLConnection.createConnection(JDBCMySQLConnection.java:42)
at com.climacon.jdbc.db.JDBCMySQLConnection.getConnection(JDBCMySQLConnection.java:51)
at com.climacon.jdbc.main.ClimaConJDBC.get_Nodeinfo_From_DB(ClimaConJDBC.java:110)
at com.climacon.gui.ClimaCon2$5.actionPerformed(ClimaCon2.java:279)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
I think the reason you can not access the remote mysql may be due to the remote access restriction in my.cnf
please check the line
bind-address: is set to 127.0.0.1
under this restriction, you can not connect remotely with that mysql server;
to solve this, you need to change this line to:
bind-address: 0.0.0.0
in addition you should specify the port for connection as below:
String URL = "jdbc:mysql://192.168.11.157:3306/DB_name";
because mysql will connect port 3306 in default.
wish my answer could help you!
You have to check the next things:
Is the database active? Does it respond to another application except yours?
Is the network connection OK (eg firewall)?
Check the connection strings (perhaps the port is necessairy but I am not sure).
I am not really familiar with the raspberry. It seems that it's using a linux operating system (correct me if I am wrong). In this post, instruction are given on how to disable firewall on the device. It says that the firewall is the usual iptables firewall used on linux systems. I find this iptables tutorial (based on ubuntu) very useful. Perhaps it would give you some guidance.
Hope I helped!
You may be able to ping the raspberry pi but I am not sure what the interface used is.
Why don't you use MySQL Ping and see if it is responding?
Else it must be a network issue. Get it resolved and then connect. No alternatives for this.
You can issue a light weight ping to your database server to check the connection availability.
Please read following discussion and articles:
Ping MySQL Server
Ping syntax and example
My answer to one of such Communication link failures.
Solved:
Go into the my.cnf file (sudo nano /etc/mysql/my.cnf) file and
look for "bind-address" and make it “bind-address = * “
Reload MySQL config (sudo service mysql reload)
Restart MySQL server (sudo service mysql restart)
The url "jdbc:mysql://localhost:3306/mydb".
You lost the port 3306.
you need to print the exception to the console ,rather than print a customer "error",If you do
as that ,you can't get the key of the problem