title: Flutter can't connect to SocketIO
body: <p>I'm a newbie in Flutter.</p>
  <p>I want to build an application that triggers an alarm when event is incoming. so I tried using SocketIO as a backend but I stuck with this error in Flutter's console.</p>
  <p>I build floatingActionButton for sending message test. When the button is pressed from the first phone, another phone should show 'Alert' in the debug console. But it didn't show any.</p>
  <p>This is the error when the page is showing.</p>
  <pre><code>I/flutter ( 3536): CREATING NEW SOCKET: http://localhost:8080/alert
  I/flutter ( 3536): Created
  I/flutter ( 3536): Initialized
  D/FlutterSocketIoPlugin: FlutterSocketIoPlugin( 3536): onMethodCall: socketInit - domain: http://localhost:8080 - with namespace: /alert
  D/FlutterSocketIoPlugin: TOTAL SOCKETS: ( 3536): 0
  D/FlutterSocketIoPlugin: TOTAL SOCKETS: ( 3536): 0
  D/FlutterSocketIoPlugin: added SocketIO( 3536): http://localhost:8080/alert
  D/FlutterSocketIoPlugin: SocketIO( 3536): connecting...null
  D/FlutterSocketIoPlugin: FlutterSocketIoPlugin( 3536): onMethodCall: socketSubcribes - domain: http://localhost:8080 - with namespace: /alert
  D/FlutterSocketIoPlugin: FlutterSocketIoPlugin( 3536): socketData: {&quot;alert_user&quot;:&quot;FunctionId@624955072&quot;}
  D/FlutterSocketIoPlugin: TOTAL SOCKETS: ( 3536): 1
  D/FlutterSocketIoPlugin: SocketIO( 3536): --- subscribes ---{&quot;alert_user&quot;:&quot;FunctionId@624955072&quot;}
  D/FlutterSocketIoPlugin: subscribe( 3536): channel: alert_user - with callback: FunctionId@624955072
  D/FlutterSocketIoPlugin: socketInfo( 3536): SUBSCRIBES SIZES: NULL or EMPTY
  D/FlutterSocketIoPlugin: socketInfo( 3536): SUBSCRIBES SIZES: 1
  D/FlutterSocketIoPlugin: socketInfo( 3536): CHANNEL: alert_user with TOTAL LISTENERS: 1
  D/FlutterSocketIoPlugin: FlutterSocketIoPlugin( 3536): onMethodCall: socketConnect - domain: http://localhost:8080 - with namespace: /alert
  D/FlutterSocketIoPlugin: TOTAL SOCKETS: ( 3536): 1
  D/FlutterSocketIoPlugin: SocketIO( 3536): connecting socket: http://localhost:8080/alert
  W/sinessDetectio( 3536): Accessing hidden method Ldalvik/system/CloseGuard;-&gt;get()Ldalvik/system/CloseGuard; (greylist,core-platform-api, reflection, allowed)
  W/sinessDetectio( 3536): Accessing hidden method Ldalvik/system/CloseGuard;-&gt;open(Ljava/lang/String;)V (greylist,core-platform-api, reflection, allowed)
  W/sinessDetectio( 3536): Accessing hidden method Ldalvik/system/CloseGuard;-&gt;warnIfOpen()V (greylist,core-platform-api, reflection, allowed)
  W/sinessDetectio( 3536): Accessing hidden field Lsun/misc/Unsafe;-&gt;theUnsafe:Lsun/misc/Unsafe; (greylist, reflection, allowed)
  W/sinessDetectio( 3536): Accessing hidden method Lsun/misc/Unsafe;-&gt;allocateInstance(Ljava/lang/Class;)Ljava/lang/Object; (greylist, reflection, allowed)
  D/FlutterSocketIoPlugin: SocketIO( 3536): connect_error: [{&quot;cause&quot;:{&quot;detailMessage&quot;:&quot;CLEARTEXT communication to localhost not permitted by network security policy&quot;,&quot;stackTrace&quot;:[],&quot;suppressedExceptions&quot;:[]},&quot;detailMessage&quot;:&quot;websocket error&quot;,&quot;stackTrace&quot;:[],&quot;suppressedExceptions&quot;:[]}]
  D/FlutterSocketIoPlugin: SocketIO( 3536): reconnect_attempt: [1]
  D/FlutterSocketIoPlugin: SocketIO( 3536): reconnecting: [1]
  D/FlutterSocketIoPlugin: SocketIO( 3536): connect_error: [{&quot;cause&quot;:{&quot;detailMessage&quot;:&quot;CLEARTEXT communication to localhost not permitted by network security policy&quot;,&quot;stackTrace&quot;:[],&quot;suppressedExceptions&quot;:[]},&quot;detailMessage&quot;:&quot;websocket error&quot;,&quot;stackTrace&quot;:[],&quot;suppressedExceptions&quot;:[]}]
  D/FlutterSocketIoPlugin: SocketIO( 3536): reconnect_error: [{&quot;cause&quot;:{&quot;cause&quot;:{&quot;detailMessage&quot;:&quot;CLEARTEXT communication to localhost not permitted by network security policy&quot;,&quot;stackTrace&quot;:[],&quot;suppressedExceptions&quot;:[]},&quot;detailMessage&quot;:&quot;websocket error&quot;,&quot;stackTrace&quot;:[],&quot;suppressedExceptions&quot;:[]},&quot;detailMessage&quot;:&quot;Connection error&quot;,&quot;stackTrace&quot;:[],&quot;suppressedExceptions&quot;:[]}]
  </code></pre>
  <p>It continues to give me this error all the time.</p>
  <p>Console from pressing floatingActionButton in the first phone.</p>
  <pre><code>D/FlutterSocketIoPlugin: FlutterSocketIoPlugin( 5570): onMethodCall: socketSendMessage - domain: http://localhost:8080 - with namespace: /alert
  D/FlutterSocketIoPlugin: TOTAL SOCKETS: ( 5570): 1
  D/FlutterSocketIoPlugin: SocketIO( 5570): socket id: http://localhost:8080/alert is connected: false
  </code></pre>
  <p>This is my server code</p>
  <pre><code>const app = require(&quot;express&quot;)();
  const server = require(&quot;http&quot;).createServer(app);
  const io = require(&quot;socket.io&quot;)(server);
  const PORT = process.env.PORT || 8080;
  
  server.listen(PORT);
  console.log(&quot;Server is Running on Port &quot; + PORT);
  
  app.get(&quot;/&quot;, (req, res) =&gt; {
    res.send(&quot;Node Server is running. Yay!!&quot;);
  });
  
  const alert = io.of(&quot;/alert&quot;);
  
  alert.on(&quot;connection&quot;, (socket) =&gt; {
    console.log(socket.id, &quot;joined&quot;);
  
    socket.on(&quot;alert_detect&quot;, (data) =&gt; {
      alert.emit(&quot;alert_user&quot;, data);
    });
  });
  </code></pre>
  <p>and this is my Flutter code</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:flutter_socket_io/flutter_socket_io.dart';
  import 'package:flutter_socket_io/socket_io_manager.dart';
  
  class MainScreen extends StatefulWidget {
    static const routeName = '/main-screen';
    @override
    _MainScreenState createState() =&gt; _MainScreenState();
  }
  
  class _MainScreenState extends State&lt;MainScreen&gt; {
    SocketIO socketIO;
  
    @override
    void initState() {
      _initSocketIO();
      super.initState();
    }
  
    _initSocketIO() {
      socketIO = SocketIOManager().createSocketIO(
        'http://localhost:8080',
        '/alert',
      );
      print('Created');
      socketIO.init();
      print('Initialized');
      socketIO.subscribe('alert_user', _socketAlert);
      socketIO.connect();
    }
  
    _socketAlert() {
      print('Alert');
    }
  
    void _sendMessage(msg) async {
      if (socketIO != null) {
        String jsonData = '{msg: msg,id: 1}';
        socketIO.sendMessage(&quot;alert_detect&quot;, jsonData);
      }
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: &lt;My body&gt;,
        // This is sending test
        floatingActionButton: FloatingActionButton(
          backgroundColor: Theme.of(context).primaryColor,
          child: Icon(Icons.alarm),
          onPressed: () {
            _sendMessage('Hi');
          },
        ),
      );
    }
  }
  
  </code></pre>
  <p>Do I misunderstand something?
  Thank you. :D</p>