title: Failed to connect to Websocket on iPhone
body: <p>I am working on my project and it runs <strong>perfectly fine on my IOS simulator</strong> (from emulator, I can access to my server hosted on <code>Google Instance VM</code>, <code>websocket</code> worked just fine). However, when I run it on the real device, it cannot connect to my server (<code>Django</code> with <code>channels</code> and <code>redis</code>, <code>Nginx</code>) to get the data</p>
  
  <p>When I checked on the xcode log, I saw a lot of error like this </p>
  
  <pre><code>2018-04-12 19:30:28.137787+1000 mobile[3481:2168168] TCP Conn 0x1c0365e80 Failed : error 0:61 [61]
  2018-04-12 19:30:28.198073+1000 mobile[3481:2168168] [] nw_connection_get_connected_socket 310 Connection has no connected handler
  2018-04-12 19:30:28.198184+1000 mobile[3481:2168168] TCP Conn 0x1c4172c00 Failed : error 0:61 [61]
  2018-04-12 19:30:28.323076+1000 mobile[3481:2167866] [] nw_connection_get_connected_socket 311 Connection has no connected handler
  2018-04-12 19:30:28.323190+1000 mobile[3481:2167866] TCP Conn 0x1c0367680 Failed : error 0:61 [61]
  2018-04-12 19:30:28.452909+1000 mobile[3481:2167866] [] nw_connection_get_connected_socket 312 Connection has no connected handler
  2018-04-12 19:30:28.453017+1000 mobile[3481:2167866] TCP Conn 0x1c03675c0 Failed : error 0:61 [61]
  2018-04-12 19:30:28.589833+1000 mobile[3481:2167866] [] nw_connection_get_connected_socket 313 Connection has no connected handler
  2018-04-12 19:30:28.589946+1000 mobile[3481:2167866] TCP Conn 0x1c03675c0 Failed : error 0:61 [61]
  2018-04-12 19:30:28.643707+1000 mobile[3481:2168168] [] nw_socket_connect connectx failed (fd 16, 127.0.0.1:8097 stream, pid: 3481) [61: Connection refused]
  2018-04-12 19:30:28.647380+1000 mobile[3481:2167866] [] nw_connection_get_connected_socket 314 Connection has no connected handler
  </code></pre>
  
  <p>My websocket code on the mobile is quite simple and it used the standard <code>websocket</code> from React Native (<a href="https://facebook.github.io/react-native/docs/network.html" rel="nofollow noreferrer">https://facebook.github.io/react-native/docs/network.html</a>) </p>
  
  <pre><code>    socket.onopen = () =&gt; {
  
          };
  
          socket.onmessage = (e) =&gt; {
  
          };
  
          socket.onerror = (e) =&gt; {
            console.log(e.message);
          };
  
          socket.onclose = (e) =&gt; {
            console.log(e.code, e.reason);
          };
  </code></pre>
  
  <p>My Nginx configuration is like this </p>
  
  <pre><code>server {
  listen 80;
  location / {
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
      proxy_set_header X-Real-IP  $remote_addr;
      proxy_set_header X-Forwarded-For $remote_addr;
      proxy_set_header Host $host;
      proxy_pass http://127.0.0.1:8000;
   }
  }
  </code></pre>
  
  <p>Is there anyone having the same issue ? It is really disappointed that I used the native WebSocket from React Native and it does not work like expected, but before that, in the previous version of my app, I used "socket.io" and it worked just fine. I am using <code>react native 0.50</code></p>