Javascript 尝试连接到Scalecube'时收到400个错误请求;s Socket.IO Java服务器

Javascript 尝试连接到Scalecube'时收到400个错误请求;s Socket.IO Java服务器,javascript,java,sockets,socket.io,Javascript,Java,Sockets,Socket.io,我正在使用Scalecube的Socket.IO Java服务器(如他们的示例中所述),从我的Java后端向前端侦听套接字的javascript代码发送消息。不幸的是,我无法完成套接字连接。我不断从localhost:5000上的套接字收到400个错误请求 我做错了什么 前端 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Soc

我正在使用Scalecube的Socket.IO Java服务器(如他们的示例中所述),从我的Java后端向前端侦听套接字的javascript代码发送消息。不幸的是,我无法完成套接字连接。我不断从
localhost:5000上的套接字收到400个错误请求

我做错了什么

前端

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Socket.IO</title>
    <script src="socket.io.js"></script>
    <script>
        var socket = io('http://localhost:5000');
        socket.on('connect', function(){
            console.log('connect');
        });
        socket.on('event', function(data){
            console.log(data);
        });
        socket.on('disconnect', function(){
            console.log('disconnect');
        });
    </script>
</head>
<body>
</body>
</html>
package test;

import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil;
import io.scalecube.socketio.Session;
import io.scalecube.socketio.SocketIOAdapter;
import io.scalecube.socketio.SocketIOServer;
import org.apache.log4j.BasicConfigurator;

public class Test {
    public static void main(String [] args) {
        BasicConfigurator.configure();

        SocketIOServer echoServer = SocketIOServer.newInstance(5000);
        echoServer.setListener(new SocketIOAdapter() {
            @Override
            public void onConnect(Session session) {
                System.out.println("Connected: " + session);
            }

            @Override
            public void onMessage(Session session, ByteBuf message) {
                System.out.println("Received: " + message.toString(CharsetUtil.UTF_8));
                message.release();
            }

            @Override
            public void onDisconnect(Session session) {
                System.out.println("Disconnected: " + session);
            }
        });
        echoServer.start();
    }
}
pom.xml

<project>
    <groupId>test</groupId>
    <artifactId>test</artifactId>
    <version>1.0.0</version>
    <modelVersion>4.0.0</modelVersion>

    <dependencies>
        <dependency>
            <groupId>io.scalecube</groupId>
            <artifactId>socketio</artifactId>
            <version>2.3.4</version>
        </dependency>
        <dependency>
            <groupId>antlr</groupId>
            <artifactId>antlr</artifactId>
            <version>2.7.7</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-buffer</artifactId>
            <version>4.1.6.Final</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-common</artifactId>
            <version>4.1.6.Final</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-handler</artifactId>
            <version>4.1.6.Final</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec</artifactId>
            <version>4.1.6.Final</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec-http</artifactId>
            <version>4.1.6.Final</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport</artifactId>
            <version>4.1.6.Final</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport-native-epoll</artifactId>
            <version>4.1.6.Final</version>
            <classifier>linux-x86_64</classifier>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.5</version>
        </dependency>
    </dependencies>
</project>

测试
测试
1.0.0
4.0.0
伊奥·斯卡莱克贝
索克蒂奥
2.3.4
antlr
antlr
2.7.7
伊奥·内蒂
网状缓冲器
4.1.6.最终版本
伊奥·内蒂
荨麻
4.1.6.最终版本
伊奥·内蒂
内蒂处理程序
4.1.6.最终版本
伊奥·内蒂
netty编解码器
4.1.6.最终版本
伊奥·内蒂
netty编解码器http
4.1.6.最终版本
伊奥·内蒂
网状运输
4.1.6.最终版本
伊奥·内蒂
netty传输本地epoll
4.1.6.最终版本
linux-x86_64
org.slf4j
slf4j-log4j12
1.7.5
日志和错误消息

相关错误出现在最后几行

0 [main] INFO io.scalecube.socketio.SocketIOServer  - Socket.IO server starting
35 [main] DEBUG io.netty.util.internal.logging.InternalLoggerFactory  - Using SLF4J as the default logging framework
81 [main] DEBUG io.netty.util.ResourceLeakDetector  - -Dio.netty.leakDetection.level: simple
81 [main] DEBUG io.netty.util.ResourceLeakDetector  - -Dio.netty.leakDetection.maxRecords: 4
133 [main] DEBUG io.netty.util.internal.PlatformDependent0  - java.nio.Buffer.address: available
135 [main] DEBUG io.netty.util.internal.PlatformDependent0  - sun.misc.Unsafe.theUnsafe: available
137 [main] DEBUG io.netty.util.internal.PlatformDependent0  - sun.misc.Unsafe.copyMemory: available
137 [main] DEBUG io.netty.util.internal.PlatformDependent0  - direct buffer constructor: available
139 [main] DEBUG io.netty.util.internal.PlatformDependent0  - java.nio.Bits.unaligned: available, true
139 [main] DEBUG io.netty.util.internal.PlatformDependent0  - java.nio.DirectByteBuffer.<init>(long, int): available
141 [main] DEBUG io.netty.util.internal.Cleaner0  - java.nio.ByteBuffer.cleaner(): available
142 [main] DEBUG io.netty.util.internal.PlatformDependent  - Java version: 8
143 [main] DEBUG io.netty.util.internal.PlatformDependent  - -Dio.netty.noUnsafe: false
143 [main] DEBUG io.netty.util.internal.PlatformDependent  - sun.misc.Unsafe: available
143 [main] DEBUG io.netty.util.internal.PlatformDependent  - -Dio.netty.noJavassist: false
144 [main] DEBUG io.netty.util.internal.PlatformDependent  - Javassist: unavailable
144 [main] DEBUG io.netty.util.internal.PlatformDependent  - You don't have Javassist in your class path or you don't have enough permission to load dynamically generated classes.  Please check the configuration for better performance.
144 [main] DEBUG io.netty.util.internal.PlatformDependent  - -Dio.netty.tmpdir: /var/folders/gf/nk5vq4s13js9l91p8414w4x80000gr/T (java.io.tmpdir)
145 [main] DEBUG io.netty.util.internal.PlatformDependent  - -Dio.netty.bitMode: 64 (sun.arch.data.model)
145 [main] DEBUG io.netty.util.internal.PlatformDependent  - -Dio.netty.noPreferDirect: false
145 [main] DEBUG io.netty.util.internal.PlatformDependent  - io.netty.maxDirectMemory: 1908932608 bytes
146 [main] DEBUG io.netty.util.ResourceLeakDetectorFactory  - Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector@1b9e1916
220 [main] DEBUG io.netty.util.internal.PlatformDependent  - org.jctools-core.MpscChunkedArrayQueue: available
252 [main] WARN io.scalecube.socketio.DefaultServerBootstrapFactory  - Env doesn't support epoll transport
272 [main] DEBUG io.netty.channel.MultithreadEventLoopGroup  - -Dio.netty.eventLoopThreads: 8
427 [main] DEBUG io.netty.channel.nio.NioEventLoop  - -Dio.netty.noKeySetOptimization: false
428 [main] DEBUG io.netty.channel.nio.NioEventLoop  - -Dio.netty.selectorAutoRebuildThreshold: 512
488 [main] DEBUG io.netty.buffer.PooledByteBufAllocator  - -Dio.netty.allocator.numHeapArenas: 8
488 [main] DEBUG io.netty.buffer.PooledByteBufAllocator  - -Dio.netty.allocator.numDirectArenas: 8
488 [main] DEBUG io.netty.buffer.PooledByteBufAllocator  - -Dio.netty.allocator.pageSize: 8192
488 [main] DEBUG io.netty.buffer.PooledByteBufAllocator  - -Dio.netty.allocator.maxOrder: 11
488 [main] DEBUG io.netty.buffer.PooledByteBufAllocator  - -Dio.netty.allocator.chunkSize: 16777216
488 [main] DEBUG io.netty.buffer.PooledByteBufAllocator  - -Dio.netty.allocator.tinyCacheSize: 512
488 [main] DEBUG io.netty.buffer.PooledByteBufAllocator  - -Dio.netty.allocator.smallCacheSize: 256
488 [main] DEBUG io.netty.buffer.PooledByteBufAllocator  - -Dio.netty.allocator.normalCacheSize: 64
488 [main] DEBUG io.netty.buffer.PooledByteBufAllocator  - -Dio.netty.allocator.maxCachedBufferCapacity: 32768
488 [main] DEBUG io.netty.buffer.PooledByteBufAllocator  - -Dio.netty.allocator.cacheTrimInterval: 8192
530 [main] DEBUG io.netty.buffer.ByteBufUtil  - -Dio.netty.allocator.type: pooled
531 [main] DEBUG io.netty.buffer.ByteBufUtil  - -Dio.netty.threadLocalDirectBufferSize: 65536
531 [main] DEBUG io.netty.buffer.ByteBufUtil  - -Dio.netty.maxThreadLocalCharBufferSize: 16384
541 [main] DEBUG io.netty.buffer.AbstractByteBuf  - -Dio.netty.buffer.bytebuf.checkAccessible: true
542 [main] DEBUG io.netty.util.ResourceLeakDetectorFactory  - Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector@880ec60
638 [main] DEBUG io.netty.channel.DefaultChannelId  - -Dio.netty.processId: 23090 (auto-detected)
642 [main] DEBUG io.netty.util.NetUtil  - -Djava.net.preferIPv4Stack: false
643 [main] DEBUG io.netty.util.NetUtil  - -Djava.net.preferIPv6Addresses: false
644 [main] DEBUG io.netty.util.NetUtil  - Loopback interface: lo0 (lo0, 0:0:0:0:0:0:0:1)
644 [main] DEBUG io.netty.util.NetUtil  - /proc/sys/net/core/somaxconn: 128 (non-existent)
683 [main] DEBUG io.netty.channel.DefaultChannelId  - -Dio.netty.machineId: 9c:f3:87:ff:fe:d6:8b:b6 (auto-detected)
683 [main] DEBUG io.netty.util.internal.ThreadLocalRandom  - -Dio.netty.initialSeedUniquifier: 0xe4fdf6d1b06bd83e
790 [main] INFO io.scalecube.socketio.SocketIOServer  - Socket.IO server started: ServerConfiguration{port=5000, ssl=false, heartbeatTimeout=60, heartbeatInterval=25, closeTimeout=60, transports='websocket,flashsocket,xhr-polling,jsonp-polling', alwaysSecureWebSocketLocation=false, remoteAddressHeader=null, eventExecutorEnabled=true, eventExecutorThreadNumber=8, maxWebSocketFrameSize=65536, epollEnabled=true, httpCompressionEnabled=false, websocketCompressionEnabled=false}
24863 [socketio-io-3-1] DEBUG io.netty.util.Recycler  - -Dio.netty.recycler.maxCapacityPerThread: 32768
24864 [socketio-io-3-1] DEBUG io.netty.util.Recycler  - -Dio.netty.recycler.maxSharedCapacityFactor: 2
24864 [socketio-io-3-1] DEBUG io.netty.util.Recycler  - -Dio.netty.recycler.linkCapacity: 16
24864 [socketio-io-3-1] DEBUG io.netty.util.Recycler  - -Dio.netty.recycler.ratio: 8
24877 [defaultEventExecutorGroup-4-1] DEBUG io.scalecube.socketio.pipeline.PacketDispatcherHandler  - Channel active: [id: 0x3268fa6e, L:/0:0:0:0:0:0:0:1:5000 - R:/0:0:0:0:0:0:0:1:65515]
24901 [socketio-io-3-1] WARN io.scalecube.socketio.pipeline.HandshakeHandler  - Received HTTP bad request: GET /socket.io/ from channel: [id: 0x3268fa6e, L:/0:0:0:0:0:0:0:1:5000 - R:/0:0:0:0:0:0:0:1:65515]
24916 [defaultEventExecutorGroup-4-1] DEBUG io.scalecube.socketio.pipeline.PacketDispatcherHandler  - Channel inactive: [id: 0x3268fa6e, L:/0:0:0:0:0:0:0:1:5000 ! R:/0:0:0:0:0:0:0:1:65515]
26411 [defaultEventExecutorGroup-4-2] DEBUG io.scalecube.socketio.pipeline.PacketDispatcherHandler  - Channel active: [id: 0x8e67ba8d, L:/0:0:0:0:0:0:0:1:5000 - R:/0:0:0:0:0:0:0:1:65524]
26412 [socketio-io-3-2] WARN io.scalecube.socketio.pipeline.HandshakeHandler  - Received HTTP bad request: GET /socket.io/ from channel: [id: 0x8e67ba8d, L:/0:0:0:0:0:0:0:1:5000 - R:/0:0:0:0:0:0:0:1:65524]
26415 [defaultEventExecutorGroup-4-2] DEBUG io.scalecube.socketio.pipeline.PacketDispatcherHandler  - Channel inactive: [id: 0x8e67ba8d, L:/0:0:0:0:0:0:0:1:5000 ! R:/0:0:0:0:0:0:0:1:65524]
28951 [defaultEventExecutorGroup-4-3] DEBUG io.scalecube.socketio.pipeline.PacketDispatcherHandler  - Channel active: [id: 0x874367ca, L:/0:0:0:0:0:0:0:1:5000 - R:/0:0:0:0:0:0:0:1:65533]
28953 [socketio-io-3-3] WARN io.scalecube.socketio.pipeline.HandshakeHandler  - Received HTTP bad request: GET /socket.io/ from channel: [id: 0x874367ca, L:/0:0:0:0:0:0:0:1:5000 - R:/0:0:0:0:0:0:0:1:65533]
28955 [defaultEventExecutorGroup-4-3] DEBUG io.scalecube.socketio.pipeline.PacketDispatcherHandler  - Channel inactive: [id: 0x874367ca, L:/0:0:0:0:0:0:0:1:5000 ! R:/0:0:0:0:0:0:0:1:65533]
0[main]INFO io.scalecube.socketio.SocketIOServer-Socket.io服务器正在启动
35[main]调试io.netty.util.internal.logging.InternalLoggerFactory-使用SLF4J作为默认日志框架
81[main]调试io.netty.util.ResourceLeakDetector---Dio.netty.leakDetection.level:简单
81[main]调试io.netty.util.ResourceLeakDetector---Dio.netty.leakDetection.maxRecords:4
133[main]DEBUG io.netty.util.internal.PlatformDependent0-java.nio.Buffer.address:可用
135[main]调试io.netty.util.internal.PlatformDependent0-sun.misc.Unsafe.theUnsafe:可用
137[main]调试io.netty.util.internal.PlatformDependent0-sun.misc.Unsafe.copyMemory:可用
137[main]调试io.netty.util.internal.PlatformDependent0-直接缓冲区构造函数:可用
139[main]DEBUG io.netty.util.internal.PlatformDependent0-java.nio.Bits.unaligned:可用,true
139[main]DEBUG io.netty.util.internal.PlatformDependent0-java.nio.DirectByteBuffer.(long,int):可用
141[main]DEBUG io.netty.util.internal.Cleaner0-java.nio.ByteBuffer.cleaner():可用
142[main]调试io.netty.util.internal.PlatformDependent-Java版本:8
143[main]调试io.netty.util.internal.PlatformDependent---Dio.netty.noUnsafe:false
143[main]调试io.netty.util.internal.PlatformDependent-sun.misc.Unsafe:可用
143[main]调试io.netty.util.internal.PlatformDependent---Dio.netty.noJavassist:false
144[main]调试io.netty.util.internal.PlatformDependent-Javassist:不可用
144[main]DEBUG io.netty.util.internal.PlatformDependent-您的类路径中没有Javassist,或者您没有足够的权限加载动态生成的类。请检查配置以获得更好的性能。
144[main]调试io.netty.util.internal.PlatformDependent--Dio.netty.tmpdir:/var/folders/gf/nk5vq4s13js9l91p8414w4x8000gr/T(java.io.tmpdir)
145[main]调试io.netty.util.internal.PlatformDependent---Dio.netty.bitMode:64(sun.arch.data.model)
145[main]调试io.netty.util.internal.PlatformDependent---Dio.netty.noPreferDirect:false
145[main]调试io.netty.util.internal.PlatformDependent-io.netty.maxDirectMemory:1908932608字节
146[main]调试io.netty.util.ResourceLeakDetectorFactory-加载的默认ResourceLeakDetector:io.netty.util。ResourceLeakDetector@1b9e1916
220[main]DEBUG io.netty.util.internal.PlatformDependent-org.jctools-core.MpscChunkedArrayQueue:可用
252[main]WARN io.scalecube.socketio.DefaultServerBootstrapFactory-环境不支持epoll传输
272[main]调试io.netty.channel.MultithreadEventLoopGroup---Dio.netty.eventLoopThreads:8
427[main]调试io.netty.channel.nio.NioEventLoop---Dio.netty.nokeys优化:false
428[主]调试io.netty.channel.nio.NIEVENTLOOP---Dio.netty.SELECTOR自动重建阈值:512
488[main]调试io.netty.buffer.POOLEDBYTEBUFFALLOCATOR---Dio.netty.allocator.numHeapArenas:8
488[main]调试io.netty.buffer.POOLEDBYTEBUFFALLOCATOR---Dio.netty.allocator.numDirectArenas:8
488[main]调试io.netty.buffer.POOLEDBYTEBUFFALLOCATOR---Dio.netty.allocator.pageSize:8192
488[main]调试io.netty.buffer.POOLEDBYTEBUFFALLOCATOR---Dio.netty.allocator.MAXDORDER:11
488[main]调试io.netty.buffer.POOLEDBYTEBUFFALLOCATOR---Dio.netty.allocator.chunkSize:16777216
488[main]调试io.netty.buffer.POOLEDBYTEBUFFALLOCATOR---Dio.netty.allocator.tinyCacheSize:512
488[main]调试io.netty.buffer.POOLEDBYTEBUFFALLOCATOR---Dio.netty.allocator.smallCacheSize:256
488[main]调试io.netty.buffer.POOLEDBYTEBUFFALLOCATOR---Dio.netty.allocator.normalCacheSize:64
488[main]调试io.netty.buffer.POOLEDBYTEBUFFALLOCATOR---Dio.netty.allocator.MAXCACHEDBBUFFERCAPACITY:32768
488[main]调试io.netty.buffer.POOLEDBYTEBUFFALLOCATOR---Dio.netty.allocator.CACHETRIMPERVAL:8192
530[main]调试io.netty.buffer.ByteBufUtil---Dio.netty.allocator.type:pooled
531[main]调试io.netty.buffer.ByteBufUtil---Dio.netty.threadLocalDirectBufferSize:65536
531[main]调试io.netty.buffer.ByteBufUtil---Dio.netty.maxThreadLocalCharBufferSize:16384
541[main]调试io.netty.buffer.AbstractByteBuf---Dio.netty.buffer.bytebuf.checkAccessible:true
542[main]调试io.netty.util.ResourceLeakDetectorFactory-加载的默认ResourceLeakDetector:io.netty.util。ResourceLeakDetector@880ec60
638[main]调试io.netty.channel.DefaultChannelId
<dependency>
    <groupId>com.corundumstudio.socketio</groupId>
    <artifactId>netty-socketio</artifactId>
    <version>1.7.12</version>
</dependency>