Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用UnityWebSocket库进行连接,服务端有收到Socket并提示Socket连接建立,但客户端的Socket状态仍然为Connecting #1795

Closed
wszhhx opened this issue Sep 23, 2023 · 2 comments

Comments

@wszhhx
Copy link

wszhhx commented Sep 23, 2023

The Issues is for bug report only.

Goto Discussions for feature request , questions, etc.

Update to master branch HEAD first, and

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior.

Additional context
Add any other context about the problem here.

@wszhhx wszhhx closed this as completed Sep 23, 2023
@wszhhx
Copy link
Author

wszhhx commented Sep 23, 2023

做了几组对照试验:
1.用examples的Client连接skynet正常建立连接
2.本地客户端连接用Java搭建的服务端,正常建立socket连接
3.本地客户端连接skynet的example服务器,情况如本issue标题所示
4.用C#的System.Net.WebSocket库连接skynet的example服务器,情况如本issue标题所示
5.服务端调用socket.close_fd()时,客户端的socket状态会立即从connecting变成close

Ip地址与Port没问题
防火墙出站入战也没问题
抓包也正常发现了三次握手的包

然道是因为websocket不兼容?求大牛明示~
这是用UnityWebSocket库连接时,skynet的example服务器报的Log,内容与用skynet的client连接报的Log一样,看服务端这边的Log是无异常,区别就是客户端这里socket状态永远是Connecting。
1695457708370_B2DC238F-2744-4360-BE11-AA8207B9B98C

@wszhhx wszhhx reopened this Sep 23, 2023
@wszhhx wszhhx changed the title 使用Unity 使用UnityWebSocket库进行连接,服务端有收到Socket并提示Socket连接建立,但客户端的Socket状态仍然为Connecting Sep 23, 2023
@wszhhx
Copy link
Author

wszhhx commented Sep 23, 2023

客户端调用UnityWebSocket代码:
public void Connect(string _ip, int _port)
{
if (m_socket != null)
{
if (m_socket.ReadyState == WebSocketState.Open
|| m_socket.ReadyState == WebSocketState.Connecting
|| m_socket.ReadyState == WebSocketState.Closing)
{
return;
}
}
m_socket = new WebSocket($"ws://{_ip}:{_port}");
m_socket.OnOpen += OnConnected;
m_socket.OnError += OnConnectFail;
m_socket.OnMessage += OnReceiveMessage;
m_socket.OnClose += OnClosed;
m_socket.ConnectAsync();
}

Repository owner locked and limited conversation to collaborators Sep 23, 2023
@cloudwu cloudwu converted this issue into discussion #1796 Sep 23, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant