NutzCN Logo
问答 ngrok 过一段时间会自动断开
发布于 2760天前 作者 Rekoe 3274 次浏览 复制 上一个帖子 下一个帖子
标签:

RT
好像心跳包没起到作用,每次断开后 重新请求2~3次连接才能重新连接上!

19 回复

连nutzcn的ngrok也是这样吗?

@wendal
就是一直用的nutzcn的 java的那个客户端 还有ngrok.exe的那个同样的问题

我是说, 连的是nutzcn的ngrok服务吗? 不是指客户端

待我调查一下

@wendal 那个心跳可以一直ping吧 兽

心跳是心跳线程

ProxyConnection没有心跳

之前改的就是, 不写数据的话, 没法判断ProxyConnection是否已经断开

所以我改成先写数据,能写入就是好的,然后再继续

@wendal
断开的时候 有这个日志

2017-4-25 21:31:50.893 DEBUG [pool-1-thread-1692] proxy conn exit first at loc2srv
2017-4-25 21:31:50.893 DEBUG [pool-1-thread-1701] srv2loc 120010ms 0kb
2017-4-25 21:31:51.124 DEBUG [pool-1-thread-1704] loc2srv 120000ms 1kb
2017-4-25 21:31:51.125 DEBUG [pool-1-thread-1693] proxy conn exit first at loc2srv
2017-4-25 21:31:51.125 DEBUG [pool-1-thread-1703] srv2loc 120002ms 0kb
2017-4-25 21:31:53.863 DEBUG [pool-1-thread-1706] loc2srv 120010ms 7kb
2017-4-25 21:31:53.864 DEBUG [pool-1-thread-1694] proxy conn exit first at loc2srv
2017-4-25 21:31:53.864 DEBUG [pool-1-thread-1705] srv2loc 120011ms 0kb
2017-4-25 21:31:54.403 DEBUG [pool-1-thread-1713] loc2srv 120001ms 1kb
2017-4-25 21:31:54.404 DEBUG [pool-1-thread-1707] proxy conn exit first at loc2srv
2017-4-25 21:31:54.404 DEBUG [pool-1-thread-1712] srv2loc 120002ms 0kb

想到个办法,反正一小时timeout,那我改成半小时就主动断开??

把ProxyConnection断开

就是加个服务器端的检测线程

那是不是 客户端超过一半小时 没有请求 还会断开连接?

另外 心跳只是为了 检查连接是否在线么 不会起到保持连接的作用么 ?

超时后的错误

2017-4-25 23:31:23.201 DEBUG [pool-1-thread-1] io error, main contrl connection break
java.io.EOFException
	at java.io.DataInputStream.readFully(DataInputStream.java:197)
	at java.io.DataInputStream.readFully(DataInputStream.java:169)
	at org.nutz.plugins.ngrok.common.NgrokAgent.readMsg(NgrokAgent.java:48)
	at org.nutz.plugins.ngrok.client.NgrokClient.handle(NgrokClient.java:207)
	at org.nutz.plugins.ngrok.client.NgrokClient._run(NgrokClient.java:193)
	at org.nutz.plugins.ngrok.client.NgrokClient.run(NgrokClient.java:150)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2017-4-25 23:31:33.279 DEBUG [pool-1-thread-1737] heartbeat exit. Contrl Conntion close?
java.net.SocketException: Socket is closed
	at sun.security.ssl.SSLSocketImpl.checkEOF(SSLSocketImpl.java:1532)
	at sun.security.ssl.SSLSocketImpl.checkWrite(SSLSocketImpl.java:1553)
	at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:71)
	at java.io.OutputStream.write(OutputStream.java:75)
	at org.nutz.plugins.ngrok.common.NgrokAgent.writeMsg(NgrokAgent.java:38)
	at org.nutz.plugins.ngrok.common.NgrokMsg.write(NgrokMsg.java:118)
	at org.nutz.plugins.ngrok.client.NgrokClient$PingThread.call(NgrokClient.java:376)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2017-4-25 23:31:53.272 DEBUG [pool-1-thread-1] something happen
2017-4-26 7:59:10.991 DEBUG [pool-1-thread-1] io error, main contrl connection break
java.io.EOFException
	at java.io.DataInputStream.readFully(DataInputStream.java:197)
	at java.io.DataInputStream.readFully(DataInputStream.java:169)
	at org.nutz.plugins.ngrok.common.NgrokAgent.readMsg(NgrokAgent.java:48)
	at org.nutz.plugins.ngrok.client.NgrokClient.handle(NgrokClient.java:207)
	at org.nutz.plugins.ngrok.client.NgrokClient._run(NgrokClient.java:193)
	at org.nutz.plugins.ngrok.client.NgrokClient.run(NgrokClient.java:150)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2017-4-26 7:59:24.732 DEBUG [pool-1-thread-1743] heartbeat exit. Contrl Conntion close?
java.net.SocketException: Socket is closed
	at sun.security.ssl.SSLSocketImpl.checkEOF(SSLSocketImpl.java:1532)
	at sun.security.ssl.SSLSocketImpl.checkWrite(SSLSocketImpl.java:1553)
	at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:71)
	at java.io.OutputStream.write(OutputStream.java:75)
	at org.nutz.plugins.ngrok.common.NgrokAgent.writeMsg(NgrokAgent.java:38)
	at org.nutz.plugins.ngrok.common.NgrokMsg.write(NgrokMsg.java:118)
	at org.nutz.plugins.ngrok.client.NgrokClient$PingThread.call(NgrokClient.java:376)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2017-4-26 7:59:41.79 DEBUG [pool-1-thread-1] write msg = {"Type":"Auth","Payload":{"Version":"2","MmVersion":"1.7","User":"voif52q1qih8eov2pb36jfhhq8","Passw86","ClientId":"","GzipProxy":false}}
2017-4-25 23:38:23.926 DEBUG [pool-1-thread-1] something happen
java.net.ConnectException: 拒绝连接 (Connection refused)
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)
	at sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:427)
	at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:88)
	at org.nutz.plugins.ngrok.client.NgrokClient.newSocket2Server(NgrokClient.java:251)
	at org.nutz.plugins.ngrok.client.NgrokClient._run(NgrokClient.java:161)
	at org.nutz.plugins.ngrok.client.NgrokClient.run(NgrokClient.java:150)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

尝试请求了10几次后 才重新建立了连接

这个不一样的,这个是主控socket连不上

@wendal
提示这个

Tunnel rekoe.ngrok.wendal.cn is Closed
添加回复
请先登陆
回到顶部