Socket.io: [x 2.0.3 ,the client close when your server to send chinese sentence,]

Created on 17 Nov 2017  ·  7Comments  ·  Source: socketio/socket.io

Note: for support questions, please use one of these channels: stackoverflow or slack

You want to:

  • [x] report a bug
  • [ ] request a feature

Current behaviour

Steps to reproduce (if the current behaviour is a bug)

Note: the best way to get a quick answer is to provide a failing test case, by forking the following fiddle for example.

Expected behaviour

Setup

  • OS:
  • browser:
  • socket.io version:

Other information (e.g. stacktraces, related issues, suggestions how to fix)

Most helpful comment

@Chopinsky
I konw why,maybe it was that I use “browser-sync” in debug-environment。“browser-sync” use socket.io(version 1.6.0)。I work well in release-environment。

I have solved this problem.The reason for this problem is the configuration of nginx。

Use the following configuration to work properly

   server {
        listen       3003;
        #server_name  192.168.7.114;

    location / {
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "upgrade";
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header Host $host;
         proxy_http_version 1.1;
         proxy_pass     http://192.168.7.114:3001;
    }

   location /socket.io {
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection "upgrade";
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_set_header Host $host;
             proxy_http_version 1.1;
             proxy_pass     http://192.168.7.114:3000;
   }
}

All 7 comments

in 2.0.3 ,the client will be closed when your server send a chinese sentence. the error is transport close

@wuteng606
me too(i use socket.io 2.0.4)

I couldn't reproduce this issue, I'm using express 4.16.2 and socket.io 2.0.4, and messages containing Chinese characters can be sent to/from the express server.

I suspect that some other errors took place and closed the socket connection other than the Chinese characters.

@Chopinsky
I'm using express 4.16.2 and socket.io 2.0.4 too,and I did it like this
io.of("/webPush").connected[socketId].emit('scanLogin',"一发中文就断网,啥玩意啊");
then the error is transport close.
if I use io.of("/webPush").connected[socketId].emit('scanLogin',"111");
it work well。

Are there any other settings that need to be set?(是否有其他的设置需要设置?)

@Chopinsky
I konw why,maybe it was that I use “browser-sync” in debug-environment。“browser-sync” use socket.io(version 1.6.0)。I work well in release-environment。

I have solved this problem.The reason for this problem is the configuration of nginx。

Use the following configuration to work properly

   server {
        listen       3003;
        #server_name  192.168.7.114;

    location / {
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "upgrade";
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header Host $host;
         proxy_http_version 1.1;
         proxy_pass     http://192.168.7.114:3001;
    }

   location /socket.io {
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection "upgrade";
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_set_header Host $host;
             proxy_http_version 1.1;
             proxy_pass     http://192.168.7.114:3000;
   }
}

checkout #3126

@gooddaddy
According to your configuration, it doesn't take effect

Was this page helpful?
0 / 5 - 0 ratings