xuuhaoo / OkSocket

An blocking socket client for Android applications.
MIT License
2.58k stars 433 forks source link

Socket Service 经常读取错误,导致client 离线 #202

Closed sanluku closed 2 years ago

sanluku commented 2 years ago

具体的Log如下: W/System.err: OkSocket, duplex read error,thread is dead with exception:com.xuhao.didi.core.exceptions.ReadException: read head is wrong, this socket input stream is end of file read -1 ,that mean this socket is disconnected by server I/System.out: OkSocket, server_client_read_thread is shutting down

就算head读取错误,能否不断开client呢?

Sohnia commented 2 years ago

我刚刚试了一下也是总是断开client。

sanluku commented 2 years ago

我刚刚试了一下也是总是断开client。

操作问题,Client需要Service应答,否则Client会超时断开连接

Sohnia commented 2 years ago

Reference

怎么实现呢,能否引用下代码,感激不尽

Sohnia commented 2 years ago

是不是需要服务端发心跳?

sanluku commented 2 years ago

是不是需要服务端发心跳?

服务端要回复客户端的心跳包