rikulo / socket.io-client-dart

socket.io-client-dart: Dartlang port of socket.io-client https://github.com/socketio/socket.io-client
https://quire.io
MIT License
674 stars 184 forks source link

Timeout while connecting to hardware device via Wifi #256

Open nbsathawara opened 2 years ago

nbsathawara commented 2 years ago

Hi,

I am trying to send data to a hardware device which is connected via Wifi. I have device's ip address and port number and used following code to send. But it always shows 'Connection Error : timeout'.

I am using 'socket_io_client: ^2.0.0-beta.2'

  _socket = io(
    "ws://192.168.4.1:81/",
    OptionBuilder()
        .setTransports(['websocket'])
        .enableForceNew()
        .disableAutoConnect()
        .build());
_socket.connect();
_socket.onConnect((data) =>
    {AppDebugLog.println("In onConnect : ${data.toString()}")});

_socket.onConnectError((data) => {
      AppDebugLog.println(
          "In onConnectError  : ${data.toString()}")
    });

_socket.onConnectTimeout((data) => {
      AppDebugLog.println(
          "In onConnectTimeout : ${data.toString()}")
    });

_socket.onError((data) =>
    {AppDebugLog.println("In onError : ${data.toString()}")});

_socket.onDisconnect((data) => {
      AppDebugLog.println(
          "In onDisconnect  : ${data.toString()}")
    });

I am sending data using following;

_socket?.send([msg]);

Any help will be appreciated. Thanks in advance.

saginbajracharya commented 11 months ago

same issue in my case i have a textfield to set socket server url when this url is wrong the socket dosent connet and goes to socket.on('connect_error', (data){}) and after i put the correct url it connects but soon it shows connection timeout and disconnects