Comments (13)
我没有遇到这种问题,也没有测试的服务器,我也不知道问题出来哪里
from rxwebsocket.
断开是由什么原因导致的?服务端关闭,还是出了什么异常 ?
from rxwebsocket.
我接收其他数据都正常,后台服务器发送base64图片数据就会断开,我试用了另外一个框架demo,能够正常接收到base64数据,我安卓端没报什么异常,我开始以为是服务器那边的问题,因为服务器发送图片数据安卓这边就收不到信息,会断开。今天我试了另外一个框架正常收到。
from rxwebsocket.
你有没有对接收数据长度进行限制,base64的数据有的有几十k
from rxwebsocket.
你调用代码贴一下,我看看
from rxwebsocket.
好的,谢谢大神!
MyApplication里面
/**
* 初始化WebSocket
*/
private void initWebSocket() {
Config config = new Config.Builder()
.setShowLog(true, "webSocketLog")
.setClient(new OkHttpClient.Builder()
.pingInterval(10, TimeUnit.SECONDS)// 设置心跳间隔,这个是10秒检测一次
.build())
.setReconnectInterval(10, TimeUnit.SECONDS)// 设置重连
.build();
RxWebSocket.setConfig(config);
}
MainActivity 里面
RxWebSocket.get(Const.SERVER_URL)
.subscribe(new WebSocketSubscriber() {
@OverRide
protected void onOpen(@nonnull WebSocket webSocket) {
super.onOpen(webSocket);
Log.i(TAG, "onOpen:");
}
@Override
protected void onMessage(@NonNull String text) {
super.onMessage(text);
ManageMsg(text);
LogUtil.i(TAG, "onMessage:" + text);
}
@Override
protected void onReconnect() {
super.onReconnect();
Log.i(TAG, "onReconnect:");
}
@Override
protected void onClose() {
super.onClose();
Log.i(TAG, "onClose:");
}
@Override
public void onError(Throwable e) {
super.onError(e);
Log.i(TAG, "onError:");
}
});
from rxwebsocket.
依赖的是你这个版本的implementation 'com.dhh:websocket:2.1.2'
from rxwebsocket.
你重写一下 WebSocketSubscriber 的 protected void onMessage(@nonnull ByteString byteString) 方法试试,看这个 byteString 是否有消息回调
from rxwebsocket.
protected void onMessage(@nonnull ByteString byteString) {
super.onMessage(byteString);
LogUtil.i(TAG, "onMessage:" + byteString);
}
这个收不到消息
from rxwebsocket.
03-01 13:38:14.739 31448-31448/com.runvision.g702_sn I/WebMsg: onOpen:
03-01 13:39:17.412 31448-31448/com.runvision.g702_sn I/WebMsg: onReconnect:
03-01 13:39:17.490 31448-31448/com.runvision.g702_sn I/WebMsg: onOpen:
03-01 13:39:33.364 31448-31448/com.runvision.g702_sn I/WebMsg: 删除模板
03-01 13:39:33.374 31448-31448/com.runvision.g702_sn I/WebMsg: onMessage:{"code":"202","libId":"5064","faceId":"296011","uuid":"8620"}
其他消息都接收正常,就是有base64图片消息就连接断开连接
from rxwebsocket.
好的谢谢大神
from rxwebsocket.
如果你们的测试服务器的URL可以给我的话,我可以帮忙测试一下,看看是什么问题导致的,不方便给的话,就算了。
from rxwebsocket.
可以啊,方便的,我可以加你微信或者QQ吗?因为那后台要先调用接口发送心跳让设备在线,才能进行发送web socket 消息,我的扣扣同微信396229938
from rxwebsocket.
Related Issues (20)
- 服务端的源码能否分享一下? HOT 1
- 不行啊,虽然是可以新开dispose,但是我看了本质还是同一个连接啊 HOT 4
- 断网重连方法回调的问题 HOT 1
- SocketException 后一直无法重连 HOT 2
- disposable.dispose()方法不回调onclose吗 HOT 3
- onClosing方法收到一个1011错误码后不重连 HOT 3
- 急!!!!长时间熄屏或者其他情况无消息 HOT 2
- timeout 连接 开销有点大 HOT 1
- 心跳检测 HOT 2
- 你好!发现发送大文件会失败,发送小点的图片可以,怎样可以监听发送文件的进度? HOT 1
- 服务器发布,应用会崩溃 HOT 1
- 我想一个url 多个连接咋办 HOT 3
- onReconnect()重连成功后,不会停止重连?
- setCancellable 会立即执行 HOT 7
- WebSocket连接过程中,切换wifi,重连之后再dispose无法断开WebSocket HOT 1
- 接锅回调存在多个 HOT 1
- fragment 调用注销后没有成功注销 HOT 5
- 没有失败回调 HOT 4
- RxWebsocket引起java.io.EOFException
- 开启混淆之后RxWebSocket无法使用
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 rxwebsocket.