Comments (13)
I wonder if this fixes the bug I am hunting down, with being unable to reconnect after disconnect.
from kcp-go.
it's a bug if the client immediately reconnect from the same address:port tuple
from kcp-go.
Sure, it only happens when the client uses the same port. In my case, it does.
from kcp-go.
Not really, again p2p case, the client will always reconnect from the same tuple if it performs STUN.
I know KCP doesn't handle that, as to this day I am chasing a bug that prevents us from enabling it in syncthing.
from kcp-go.
@univac490 I assume you are doing something p2p. Do you have connection issues if you start A, start B, they connect, then restart B, in our case connections from B get refused as we still think we have an active one, yet once Bs connection timeout on A (using smux), any attempt from B to connect to A or A to B fails with smux io timeouts.
from kcp-go.
@AudriusButkevicius, I'm still experimenting with KCP. I have a server and a client running on the same machine. I also have a client on a different machine. Both clients behave the same. I don't have any issues reconnecting after the connection times out (I'm also using smux).
from kcp-go.
Do you do something clever like Dial via the listening connection etc (requited for NAT punch through)
from kcp-go.
I'm using this https://github.com/jbenet/go-reuseport
from kcp-go.
is this problem fixed in the recent commits?
from kcp-go.
Yes, should be.
from kcp-go.
So this now exposes a different problem.
If you have 1 client and 1 server, and the client restarts, the packets from the server make it look like connect attempts on the client. In the end you end up with 1 listen socket on each end (no dial sockets).
What's worse is if you have short lived dial connections (for example you connect, but the other end refuses you for some reason and disconnects), the same problem is exhibited with these dial connections which become server side connections on both sides.
Even if you hit timeouts and close connections, it seems that other end doesn't get the close message (smux) in time or something and these phantom conversations are resurrected forever.
from kcp-go.
@AudriusButkevicius it's too hard to understand, can you elaborate this problem by examples?
is it due to your recent commits?
from kcp-go.
It's not due to recent commits, it's a fundamental problem with KCP due to it not having control message
I think this is what happens:
A dials to B, they connect. B is the listener.
A restarts for some reason (crash whatever).
Packets from B related to the old connection reach A after restart
A assumes it's a new connection, creates the connection in listen mode.
Both A and B end up with listen mode connections.
A fails on smux accept (as we get random packets that are not handshake)
A probably sends something back on conn.Close,
B receives the packets, resets smux timeout/keepalive
B tries to match the packet but it's a rogue handshake it doesn't understand hence discards it.
B sends smux keepalive
Goto step 3.
I had to do this to work around it: https://github.com/AudriusButkevicius/kcp-go/commit/54928af49abc3a4e5b645f42466a56cebc4a941e
from kcp-go.
Related Issues (20)
- 为什么一重启服务器端,就收不到客户端传来的信息呢
- 服务器链接超过某个数后内存暴涨 HOT 1
- 如何抵御重放攻击(How to defend against replay attacks)? HOT 1
- 用户数据过大时,会出现数据错乱问题 HOT 3
- 只能通过UDPSession.Close才能跳出readloop循环,如果通过调用SetXXXDeadline的方式,会造成协程泄露。 HOT 1
- 在穿越了NAT的P2P隧道里,使用kcp.NewConn2建立的一对连接无法成功通信
- 请教一个dynamic fec的参数问题 HOT 2
- CI
- Use of deprecated crypto libraries HOT 2
- 客户端动态fec调整问题请教 HOT 2
- [请教一下] 客户端和服务端任何一侧离线了该如何感知
- 当调用Read和Write后,修改UDPSession的超时时间不生效 HOT 1
- Data splitting and merging HOT 7
- How to handle restarts? HOT 3
- 多客户端连接连接至同一个服务器的时候,如果有一个客户端断开了,服务端就会停止广播,即使客户端重新连接,服务端也收不到任何的连接信息,需要服务端重启才能解决此问题 HOT 6
- kcp是否支持可丢失传输
- kcp-go有没有推荐的 c/c++客户端封装实现? HOT 4
- Sending big chunks of data through kcp-go
- 服务端恢复session时,恢复rcv_nxt(让服务端可以继续read)是否可行
- 新增:服务端主动对外发动链接方法
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kcp-go.