triniwiz / nativescript-socketio

Socket.IO for nativescript
Apache License 2.0
71 stars 31 forks source link

Connection through transports: ['websocket'] only #70

Closed agarzas closed 5 years ago

agarzas commented 6 years ago

Which platform(s) does your issue occur on?

Is this plugin capable of establish connections through websockets only? If I set the socket.io sever as: transports: ['websocket'] I get a lot of logs saying:

engine intercepting request for path "/socket.io/" +34s engine handling "GET" http request "/socket.io/?EIO=3&token=ABC&transport=polling" +0ms engine unknown transport "polling" +0ms

Here is my code: `socket:SocketIO

constructor(
    private _authenticationHandlerService: AuthenticationHandlerService,
    private _routerExtensions: RouterExtensions,
    private _ngZone: NgZone
) {
    let options: IOOptions = {
        query: {
            token: "ABC"
        },
        debug: true,
        forceWebsockets: true,
    }
    this.socket = new SocketIO("http://{local-ip}", options)
}`

this.socket.connect();

It only works when I set the server to accept 'polling' and then it can´t upgrade to websockets...

triniwiz commented 6 years ago

forceWebsockets: true is for ios I think android uses transports:['websocket'] I'll try adding a common prop for both platforms

NazimMertBilgi commented 4 years ago

It doesn't work in Angular. There is also no key called transports.

@triniwiz please help me

NazimMertBilgi commented 4 years ago

I solved my problem in this link. The problem was caused by my settings from Nginx.

https://github.com/socketio/socket.io/issues/1942#issuecomment-82352072