Code Monkey home page Code Monkey logo

Comments (13)

nuclearace avatar nuclearace commented on May 18, 2024

I have no idea how to set up nginx, can you provide a server that does this? Also, does this work with the javascript client correctly?

from socket.io-client-swift.

ashokrkm avatar ashokrkm commented on May 18, 2024

sure, i can. is there a way to send a private message to you?

from socket.io-client-swift.

ashokrkm avatar ashokrkm commented on May 18, 2024

yes it works with javascript and also works with https://github.com/pkyeck/socket.IO-objc correctly

from socket.io-client-swift.

ashokrkm avatar ashokrkm commented on May 18, 2024

sent.

from socket.io-client-swift.

nuclearace avatar nuclearace commented on May 18, 2024

Seems to be some kind of race condition with polling

from socket.io-client-swift.

nuclearace avatar nuclearace commented on May 18, 2024

Workaround - have it force WebSockets

let socket = SocketIOClient(socketURL: "localhost:8080", options: ["forceWebsockets": true])

from socket.io-client-swift.

nuclearace avatar nuclearace commented on May 18, 2024

Actually it looks like nginx is doing some kind of caching?

from socket.io-client-swift.

ashokrkm avatar ashokrkm commented on May 18, 2024

i have turned off the proxy buffering off

if i connect using https://github.com/pkyeck/socket.IO-objc
it works fine without any race condition and connects only once.

nginx config

    location /socket.io {
        proxy_pass http://XXXX:5000/socket.io;
        proxy_redirect off;
        proxy_buffering off;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }

from socket.io-client-swift.

nuclearace avatar nuclearace commented on May 18, 2024

I'll try to fix it tomorrow. Basically it's trying to poll constantly and getting a reply each time.

from socket.io-client-swift.

ashokrkm avatar ashokrkm commented on May 18, 2024

OK great. thanks.

it is a really basic setup.
here is the complete nginx server config, just proxies to socket.io running on port 5000 in localhost. if you want to try from your local machine anytime.

    worker_processes  auto;

    events {
        worker_connections  1024;
    }

    http {
        server {
            listen       80;
            location /socket.io {
                proxy_pass http://localhost:5000/socket.io;
                proxy_redirect off;
                proxy_buffering off;

                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
            }
        }
    }

from socket.io-client-swift.

nuclearace avatar nuclearace commented on May 18, 2024

It is a cache problem.

from socket.io-client-swift.

ashokrkm avatar ashokrkm commented on May 18, 2024

thanks for the patch, it seems to be better, connections come to node instance only once.

But nginx still gets multiple requests. Is this OK?

   ==> node.log <==
   Sat Mar 28 2015 16:14:00 GMT-0700 (PDT): connected        CDdF50Bmvmqb3kxBAAL1
   Sat Mar 28 2015 16:14:00 GMT-0700 (PDT): added tEPn 1 clients now        connected

   ==> /opt/local/logs/access_kwik.log <==
   10.0.1.22 - - [28/Mar/2015:16:13:59 -0700] "GET /socket.io/?transport=polling&b64=1 HTTP/1.1" 200 100 "-" "kwik/1 CFNetwork/711.2.23 Darwin/14.0.0"
   10.0.1.22 - - [28/Mar/2015:16:14:00 -0700] "GET /socket.io/?transport=polling&sid=CDdF50Bmvmqb3kxBAAL1&b64=1 HTTP/1.1" 200 4 "-" "kwik/1 CFNetwork/711.2.23 Darwin/14.0.0"
   10.0.1.22 - - [28/Mar/2015:16:14:00 -0700] "POST /socket.io/?transport=polling&sid=CDdF50Bmvmqb3kxBAAL1 HTTP/1.1" 200 2 "-" "kwik/1 CFNetwork/711.2.23 Darwin/14.0.0"
   10.0.1.22 - - [28/Mar/2015:16:14:00 -0700] "GET /socket.io/?transport=polling&sid=CDdF50Bmvmqb3kxBAAL1&b64=1 HTTP/1.1" 200 15 "-" "kwik/1 CFNetwork/711.2.23 Darwin/14.0.0"
   10.0.1.22 - - [28/Mar/2015:16:14:00 -0700] "POST /socket.io/?transport=polling&sid=CDdF50Bmvmqb3kxBAAL1 HTTP/1.1" 200 2 "-" "kwik/1 CFNetwork/711.2.23 Darwin/14.0.0"

from socket.io-client-swift.

oreace avatar oreace commented on May 18, 2024

i have turned off the proxy buffering off

if i connect using https://github.com/pkyeck/socket.IO-objc
it works fine without any race condition and connects only once.

nginx config

    location /socket.io {
        proxy_pass http://XXXX:5000/socket.io;
        proxy_redirect off;
        proxy_buffering off;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }

THANK YOU SO MUCH

from socket.io-client-swift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.