Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

soccer io errors on init() #9

Closed
SaabirMohamed opened this issue Apr 5, 2021 · 2 comments
Closed

soccer io errors on init() #9

SaabirMohamed opened this issue Apr 5, 2021 · 2 comments

Comments

@SaabirMohamed
Copy link

Hi Team

I am having this issue when running the init with base url
my init looks like this
flutterFeathersjs.init(baseUrl: "https://www.mysite.xyz/api/");
I.m initialising the instance from an Oninit() hook in my GetxController

flutter logs this error :
flutter: WebSocketException: Connection to 'https://www.mysite.xyz:0/socket.io/?EIO=3&transport=websocket#' was not upgraded to websocket
Notice the https://www.mysite.xyz**:0** (colon zero at the end of the url...port being added to the url in the error message)
I don't know if this is the problem why ...I am testing my backend and all configs are fine on the backend.

this is my Nginx: (for that block - its all that that's required right?)
location /api {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $http_host;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:10123;
}

all my restful services work fine via postman only when I use this lib and run this init...I get the socket upgrade issue

can someone please assist (is there something that's appending the :0 at the end of the url?)

@SaabirMohamed SaabirMohamed changed the title soccer io errors soccer io errors on init() Apr 5, 2021
@SaabirMohamed
Copy link
Author

Resolved:
I tested my project by initialising it using the heroku demo (works perfectly...thanks for making that available)
That made me focus on nginx confs ...after some googling , appears was this line in the config (lowercase "u" proxy_set_header Connection "upgrade";), just tried it as per the stackoverflow suggestion.
I added it as an extra line and added location /socket.io/ as another proxy_pass entry
the error seems to be gone (I'm able to create a test user and authenticate as well)

Maybe this will help someone else who happens to face this issue.

@Dahkenangnon
Copy link
Owner

Hi @SaabirMohamed

The problem is about your base url
Remove the leading "/" and it will work. Also, you don't need to put the port number (:'0') in the url.

To enable websocket on nginx, use just this in your server block:

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

Your must have:

https://www.mysite.xyz as baseUrl

The "flutter: WebSocketException: Connection to 'https://www.mysite.xyz:0/socket.io/?EIO=3&transport=websocket#' was not upgraded to websocket" mean that flutter_feathersjs cannot reach out the socketio server because the baseUrl is incorrect.

Let me known if this help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants