1. 程式人生 > >JSTUN 出現 java.net.BindException: Address already in use: Cannot bind

JSTUN 出現 java.net.BindException: Address already in use: Cannot bind

使用JSTUN,進行NAT穿越的時候,總是出現java.net.BindException: Address already in use: Cannot bind

換其他機器測試,沒有問題。只有自己機器執行出現這個問題。

開啟JSTUN原始碼,檢視DiscoveryTest 的 Test2() 方法  170行;

int localPort = sendSocket.getLocalPort();

InetAddress localAddress = sendSocket.getLocalAddress();
sendSocket.close();

DatagramSocket receiveSocket = new DatagramSocket(localPort, localAddress);
receiveSocket.connect(ca.getAddress().getInetAddress(), ca.getPort());
receiveSocket.setSoTimeout(timeout);

是在Socket獲取本地埠,然後再構造 DatagramSocket(localPort, localAddress);

經過除錯,原因是因為執行緒, 沒有執行到sendSocket.close(); 方法,就去執行new DataGramSocket(localPort , localAddress);

埠未關閉,就去構造新的Socket,就出現的以上異常資訊。

在close(); 之後,執行:

try {
Thread.sleep(5);
//CPU 睡眠10毫秒,否則會出現埠還未關閉,就開始執行下面的new 語句,出現埠被佔用異常(可能出四核八執行緒機器才有的問題)
} catch (InterruptedException e) {
e.printStackTrace();
}

相關推薦

JSTUN 出現 java.net.BindException: Address already in use: Cannot bind

使用JSTUN,進行NAT穿越的時候,總是出現java.net.BindException: Address already in use: Cannot bind 換其他機器測試,沒有問題。只有自己機器執行出現這個問題。 開啟JSTUN原始碼,檢視DiscoveryTes

Exception in thread "main" java.net.BindException: Address already in use: JVM_Bind

next style exception void println clas can color imp 1 import java.io.PrintStream; 2 import java.net.Socket; 3 import java.net.Serve

jmeter 運行腳本報錯 java.net.BindException: Address already in use

1.7 pan exception window mage dex cpi 並且 聚合 在win下跑jmeter時,在聚合報告中出現錯誤。打開日誌文件(前提是將日誌寫入了指定文件) 發現報錯的原因為:java.net.BindException: Address alrea

報錯:java.net.bindexception: address already in use: jvm_bind:8080

lips RoCE ava ESS build 命令 ips 顯示 exception 原因:8080端口被占用 這說明80端口(該端口是Tomcat的監聽端口)已經被其他程序占用,先用命令提示符 " netstat -ano " 命令顯示端口狀態,再在結果中找到端口,然

java.net.BindException: Address already in use: JVM_Bind

led .net 錯誤提示 ready The eclips jms failed index 在myeclipse中,啟動JBoss4.2.3,出現地址綁定異常,在server.xml中改了8080端口號,也沒有用,一樣報這個錯?22:38:09,766 WARN [S

報錯:java.net.bindexception: address already in use: jvm_bind

exceptio exc 原因 報錯 pan use ddr net exce 原因:8080端口被占用 報錯:java.net.bindexception: address already in use: jvm_bind

jmeter壓力測試報錯:java.net.BindException: Address already in use: connect

jmeter壓力測試報錯:java.net.BindException: Address already in use: connect 最近在實現介面壓力測試的時候遇到這樣的一個問題 當執行緒數持續上升到一個點的時候,執行指令碼的時候有很多報錯,如圖: java.net.BindExc

JMeter Exception: java.net.BindException: Address already in use: connect(轉)

轉自:http://twit88.com/blog/2008/07/28/jmeter-exception-javanetbindexception-address-already-in-use-connect/ JMeter異常:java.net.BindException:地址已在使用中:connect

idea java java.net.BindException "Address already in use: JVM_Bind

啟動tomcat時,報錯:java.net.BindException "Address already in use: JVM_Bind 127.0.0.1:55486 解決:報錯資訊意思是:地址已經被使用。大概就是說這個地址和埠:127.0.0.1:23480已經被其他

tomcat啟動報java.net.BindException: Address already in use: bind錯誤解決方案

繼續學習Spring Boot,我新建了一個Spring Boot的專案 ,建好專案之後,進行測試時,出現瞭如下錯誤: java.net.BindException: Address already in use: bind at sun.nio.ch.Net.bind0

Caused by: java.net.BindException: Address already in use: no further information

錯誤 Error:Abnormal build process termination: "C:\Program Files\Java\jdk1.8.0_171\bin\java" -Xmx700m -Djava.awt.headless=true -Djava.endorsed.

啟動springboot時,控制檯報錯java.net.BindException: Address already in use: bind,但仍然能顯示想要的結果

java.net.BindException: Address already in use: bind這個是埠被佔用(例如8080埠被其他程序佔用),所以需要關掉佔用我們埠的那個程序,使用cmd 輸入命令列--netstat -ano就會得到佔用我們埠的程序的pid 然後輸

httpclient請求報 java.net.BindException: Address already in use

參考文件: http://liuinsect.iteye.com/blog/1886237 http://www.iteye.com/topic/234759 http://blog.csdn.net/kobejayandy/article/details/169212

java.net.BindException: Address already in use: JVM_Bind :1099

嚴重: Failed to initialize end point associated with ProtocolHandler ["ajp-bio-1099"] java.net.BindException: Address already in use: JVM_B

jetty 啟動報錯: java.net.BindException: Address already in use

開始新的IDE和容器之旅,IDEA + Jetty,啟動jetty的時候報錯: java.net.BindException: Address already in use: 原因:埠被佔用。 查看了一下,Apache和Maven控制檯開著,於是先關閉Apache,再試,還

【解決】java.net.BindException: Address already in use: JVM_Bind

錯誤 嚴重: StandardServer.await: create[8005]: java.net.BindException: Address already in use: JVM_Bind at java.net.DualSta

埠被佔用的情況 java.net.BindException: Address already in use: bind

IDEA+jetty啟動專案control層時,報java.net.BindException: Address already in use: bind解決方案:開啟cmd netstat ano|findstr 8080taskkill -pid 6044 -f即可

80端口占用異常解決方法java.net.BindException: Address already in use: JVM_Bind:80(或8080)

pid 異常解決 exc == protocol nbsp catalina int tcp 1:Tomcat(或其他Web容器)啟動時控制臺報錯如下示: 2007-8-2 15:20:43 org.apache.coyote.http11.Http11Protocol

java.net.BindException: Address already in use: JVM_Bind :8001解決辦法

嚴重: Failed to initialize end point associated with ProtocolHandler ["http-bio-8001"] java.net.BindException: Address already in use: JVM_

Unable to open debugger port (127.0.0.1:13249): java.net.BindException "Address already in use: JVM_Bind"

ddr 更新 java image cat logs exce blog 一點 這個問題比較簡單一點,Tomcat的端口被占用了,我使用的是IDEA裏的一個熱部署插件JReble,更新了IDEA之後就發現端口被占用了,可能我電腦沒有重啟過吧, 一直被占用著,所以解決方法就