Unable To connect my flutter application to a server in another network (not a server in a local host) using package Socket.io

Viewed 107

I am trying to connect to a server (node js) using package Socket.io in another network from my flutter application but I don't know why it does not see the server. but when I connect to a server in a local host it connects

Here is part of the flutter code that connects to the server:

     @override
  void initState() {
    // TODO: implement initState
    super.initState();
    connect();
  }

  void connect() {
    try {
// Configure socket transports

      socket = io("https://car-spa.io", <String, dynamic>{
        'transports': ['websocket'],
        'autoConnect': false,
      });

      // Connect to websocket

      socket.connect();

      //Handle socket events

      socket.on('connect', (_) => print("connect: ${socket.id}"));
    } catch (e) {
      print(e.toString());
    }
  }
0 Answers
Related