mrniko / netty-socketio

Socket.IO server implemented on Java. Realtime java framework
Apache License 2.0
6.82k stars 1.65k forks source link

How to close a "Invalid namespace" connection. #693

Open Tandrow opened 5 years ago

Tandrow commented 5 years ago

I set a namespace 'netty' on server, and then i create a client connect which namespace is not 'netty', so when connected, received '44/android,"Invalid namespace"' from server, but it's remain connecting to server, so i want to close that connection, but don't know where i can handle the 'Invalid namespace' error when connecting. I'm looking forward to your help. Thank you. the sever code `@Bean public SocketIOServer socketIOServer() { com.corundumstudio.socketio.Configuration config = new com.corundumstudio.socketio.Configuration(); config.setHostname(prop.getHost()); config.setPort(prop.getPort()); config.setBossThreads(prop.getBossCount()); config.setWorkerThreads(prop.getWorkCount()); config.setOrigin(null); config.setContext("/netty"); config.setMaxHttpContentLength(prop.getMaxHttpContentLength()); config.setMaxFramePayloadLength(prop.getMaxFramePayloadLength());

    SocketIOServer ioServer = new SocketIOServer(config);
    return ioServer;
}`

the js code <script type="text/javascript"> var socket = io.connect('http://192.168.199.237:8907/android', {path: '/netty', query: { type: 'web', key: '1234567', token: '987654321' }}); socket.on('message', function (data) { console.log(data); }); </script>

zhaoxiangyu commented 4 years ago

Have you solved this problem?