踩坑:使用socket.io连接netty-socketio后台时Error: server error

RT

具体的页面控制台报错信息为:

Error: server error
    at Socket.onPacket (bundle.js:123999:23)
    at XHR.Emitter.emit (bundle.js:7702:20)
    at XHR.onPacket (bundle.js:124399:11)
    at callback (bundle.js:124876:12)
    at Array.forEach (<anonymous>)
    at XHR.onData (bundle.js:124880:99)
    at Request.Emitter.emit (bundle.js:7702:20)
    at Request.onData (bundle.js:124669:10)
    at Request.onLoad (bundle.js:124720:12)
    at XMLHttpRequest.xhr.onreadystatechange (bundle.js:124624:16)

具体前台表现为:

前台console打印报告为无限重试连接(在失败的不停止重试的情况下),后台会打印已连接的信息,随后断开并反复重试。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

具体后台体现为:(握手未完成,随后大约1分钟左右后断开)

在这里插入图片描述

导致原因:

版本不兼容。

解决方式:

请在前端使用2.x版本的socket.io
因为这个项目真的太久之前了,也没有新版的3.x和4.x的socket.io的client。
所以如果你需要使用Java搭建后台,那么需要使用在前台使用2.x的Client或者更换后台。

在这里插入图片描述
在这里插入图片描述
**

目前测试可以正常连接的版本为:

**

        <!-- https://mvnrepository.com/artifact/com.corundumstudio.socketio/netty-socketio -->
        <dependency>
            <groupId>com.corundumstudio.socketio</groupId>
            <artifactId>netty-socketio</artifactId>
            <version>1.7.19</version>
        </dependency>
    "socket.io-client": "^2.4.0",

回退2版本后测试连接正常。
在这里插入图片描述
作者在项目issue中对新版本是否支持的回复:
在这里插入图片描述

如果你想使用3.x或4.x或者未来的更新版本,你需要使用官方的后端实现方式(放弃java)或采用另一套后台:
https://github.com/socketio/engine.io-server-java
在这里插入图片描述
该项目支持4.x和3.x版本socket.io,但是目前网上的教程较少,需要自己摸索一下。

2022年4月4日21:26:16

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: 拒绝连接: node01/192.168.72.110:7077 Caused by: java.net.ConnectException: 拒绝连接 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:715) at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:330) at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:702) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:748) 23/07/07 22:44:06 ERROR StandaloneSchedulerBackend: Application has been killed. Reason: All masters are unresponsive! Giving up. 23/07/07 22:44:06 WARN StandaloneSchedulerBackend: Application ID is not initialized yet. 23/07/07 22:44:06 INFO Utils: Successfully started service 'org.apache.spark.network.netty.NettyBlockTransferService' on port 45096. 23/07/07 22:44:06 INFO NettyBlockTransferService: Server created on node01:45096 23/07/07 22:44:06 INFO BlockManager: Using org.apache.spark.storage.RandomBlockReplicationPolicy for block replication policy 23/07/07 22:44:06 INFO SparkUI: Stopped Spark web UI at http://node01:4040 23/07/07 22:44:06 INFO BlockManagerMaster: Registering BlockManager BlockManagerId(driver, node01, 45096, None) 23/07/07 22:44:06 INFO StandaloneSchedulerBackend: Shutting down all executors
07-11

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值