Comments (13)
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.
sure, i can. is there a way to send a private message to you?
from socket.io-client-swift.
yes it works with javascript and also works with https://github.com/pkyeck/socket.IO-objc correctly
from socket.io-client-swift.
sent.
from socket.io-client-swift.
Seems to be some kind of race condition with polling
from socket.io-client-swift.
Workaround - have it force WebSockets
let socket = SocketIOClient(socketURL: "localhost:8080", options: ["forceWebsockets": true])
from socket.io-client-swift.
Actually it looks like nginx is doing some kind of caching?
from socket.io-client-swift.
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.
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.
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.
It is a cache problem.
from socket.io-client-swift.
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.
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)
- Why can't I find a single tutorial or sample that ACTUALLY WORKS with socket io?
- Can't receive events HOT 2
- SocketIOClientOption.cookies ignored in Starscream with HTTPCookieStorage HOT 1
- starscream version (4.0.6) HOT 28
- Error: compiling for iOS 10.0, but module 'Starscream' has a minimum deployment target of iOS 11.0 HOT 1
- New release to solve the Starscream compile issue HOT 2
- Socket io gives a connection error when connecting back from going to background
- How to emit Audio Data to the Socket IO HOT 1
- How to Read ByteAarray Data received my Socket IO
- getting compilaton error
- Socket.IO-Client-Swift version 16 Crash on iOS 16, built with Xcode 15 HOT 6
- Does the library support socks proxy?
- Reconnect Auth Behavior
- socket.emitWithAck(...)timingOut(...) timeout callback never called HOT 2
- LOG SocketManager: Tried connecting an already active socket
- Cannot connect to server, when android client can connect HOT 3
- Privacy Manifest HOT 3
- Potential Memory Management Issue with emitWithAck and timingOut(after:) HOT 1
- How can i use SocketIO without Rosetta on Apple Silicon
- Compiling for iOS 10.0, but module 'Starscream' has a minimum deployment target of iOS 12.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from socket.io-client-swift.