triniwiz / nativescript-socketio

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

Unable to connect server on both platforms #104

Open danishashraf047 opened 3 years ago

danishashraf047 commented 3 years ago

I'm not able to connect server on both platforms. I'm attaching source code. If I'm doing wrong so please let me correct.

            import { SocketIO } from '@triniwiz/nativescript-socketio';

            var socketIO = new SocketIO("wss://eu.rtm.tiledesk.com/v2/ws", {
                query: {
                    token: "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZWJkODkwMjkyYmVmZTAwMTkwNTQ5NzMiLCJlbWFpbCI6ImFuZHJlYWxlb0B0aWxlZGVzay5jb20iLCJmaXJzdG5hbWUiOiJBbmRyZWEiLCJsYXN0bmFtZSI6IkxlbyIsImVtYWlsdmVyaWZpZWQiOnRydWUsImlhdCI6MTYwMTQ3NTYyMywiYXVkIjoiaHR0cHM6Ly90aWxlZGVzay5jb20iLCJpc3MiOiJodHRwczovL3RpbGVkZXNrLmNvbSIsInN1YiI6InVzZXIiLCJqdGkiOiJlMGZjYjkxZC1mNzg5LTRiZDItODUyMC0zZDlkNzNiNGEyMDUifQ.ZGdoGhiW80DpPBiJ5WL3TEogwj3u1zSTtDseLUf2U0s"
                },
                forceWebsockets: true
            });
            socketIO.connect();
            socketIO.on("close", () => {
                console.log('websocket is closed.');
            });
            socketIO.on("error", (error) => {
                console.log(error);
                console.log(error.toString());
                console.log('websocket error ...')
            });
            socketIO.on("message", () => {
                console.log('message.');
            });
            socketIO.on("connect", () => {
                console.log('websocket is connected.');
            });
            socketIO.on("open", () => {
                console.log('websocket is open.');
            });

Plugin version is 5.0.1 NS Android version is 7.0.1 NS iOS version is 8.0.0

I would be thankful if you could take your precious time to help me out.

triniwiz commented 3 years ago

Which version of socket.io is the server running ?

danishashraf047 commented 3 years ago

Which version of socket.io is the server running ?

Thanks for taking out your precious time. I'm trying to integrate this one https://developer.tiledesk.com/apis/realtime-api. I can't say which version is being used because I'm using their subscription. I also have tried "ws://echo.websocket.org" server with no luck. :(

triniwiz commented 3 years ago

This is for only socket.io servers if it's only websockets you need please use https://github.com/NathanaelA/nativescript-websockets/blob/master/src/README.md

danishashraf047 commented 3 years ago

This is for only socket.io servers if it's only websockets you need please use https://github.com/NathanaelA/nativescript-websockets/blob/master/src/README.md

I have tried this one, it is working fine on Android but getting 1006 error code on iOS. I also have created issue on their repo and waiting for someone help https://github.com/NathanaelA/nativescript-websockets/issues/92 but didn't get any help till now. By the way, thank you so much to give your precious time.