Socket.io connects but does not send the emit to the server and vice versa. Nginx and SSL

1

I'm using Nginx with SSL and this setting for a service to communicate with the node, when I access the address socket.io usually connects to the server but does not receive the emit or send.

location ~ ^/(atualizaUltimaPosicao|node|socket\.io) {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_pass http://127.0.0.1:3000;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection upgrade;
        proxy_set_header Host $host;

        access_log /var/log/nginx/websockets.access.log;
        error_log /var/log/nginx/websockets.error.log

      if ($uri != '/') {
        expires 30d;
      }
   }

This is my application node, so the user connects it should send the emit but the client does not arrive.

var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http, {
  origins: '*:*'
});
http.listen(3000, function() {
  console.log('Listening port 3000');
});
io.on('connection', function(socket) {
  console.log("Client connected");
  socket.emit('posicao', 'test');
  console.log("Sended");
  socket.on('disconnect', function() {
    console.log("Disconected");
  });
});

In the application log node it sends, Client connected Sended

Client code:

var socket = io.connect('https://mydomain.com.br/atualizaUltimaPosicao');
    if (socket !== undefined || socket !== null) {
        socket.on('posicao', function (data) {
            console.log(data);
    }

I think it may be some misconfiguration I made in Nginx but I do not know what it is.

Thanks for the help.

    
asked by anonymous 14.11.2016 / 12:57

0 answers