My game couldn't establish websocket connection in Google Play Instant Game environment. It works in installed app, but not in instant app.
The game is built by cocos creator, it use libwebsockets to create websocket connection.
The log is shown below.
2019-01-28 11:23:27.207 26127-26146/org.cocos2d.instant_game D/jswrapper: JS: LoadScene 0fFE2AMtJAV5i2iNn4AVze: 6.237999999997555ms
2019-01-28 11:23:27.208 26127-26146/org.cocos2d.instant_game D/jswrapper: JS: InitScene: 0.2510000000038417ms
2019-01-28 11:23:27.208 26127-26146/org.cocos2d.instant_game D/jswrapper: JS: AttachPersist: 0.21700000000419095ms
2019-01-28 11:23:27.208 26127-26146/org.cocos2d.instant_game D/jswrapper: JS: AutoRelease: 0.23000000001047738ms
2019-01-28 11:23:27.225 26127-26146/org.cocos2d.instant_game D/jswrapper: JS: Destroy: 16.660000000003492ms
2019-01-28 11:23:27.234 26127-26146/org.cocos2d.instant_game D/jswrapper: JS: Activate: 5.010000000009313ms
2019-01-28 11:23:27.235 26127-26168/org.cocos2d.instant_game D/WebSocket.cpp: scheme: wss, host: echo.websocket.org, port: 0, path:
2019-01-28 11:23:27.236 26127-26168/org.cocos2d.instant_game D/WebSocket.cpp: CA file (/data/user/0/org.cocos2d.instant_game/files/7dfa125f-cee5-4270-9603-f7a0efba19bd.2c435.pem) in writable path exists!
2019-01-28 11:23:27.236 26127-26168/org.cocos2d.instant_game D/WebSocket.cpp: NOTICE: Creating Vhost 'default' port -1, 2 protocols, IPv6 on
2019-01-28 11:23:27.256 26127-26168/org.cocos2d.instant_game D/WebSocket.cpp: WebSocket (0x9320da80) Unhandled websocket event: 32
2019-01-28 11:23:27.252 26127-26127/org.cocos2d.instant_game W/Thread-3: type=1400 audit(0.0:176): avc: denied { node_bind } for scontext=u:r:ephemeral_app:s0:c512,c768 tcontext=u:object_r:node:s0 tclass=tcp_socket permissive=0
2019-01-28 11:23:27.256 26127-26168/org.cocos2d.instant_game D/WebSocket.cpp: WebSocket (0x9320da80) Unhandled websocket event: 29
2019-01-28 11:23:27.257 26127-26168/org.cocos2d.instant_game D/WebSocket.cpp: ERR: ERROR on binding fd 58 to port 0 (-1 13)
2019-01-28 11:23:27.257 26127-26168/org.cocos2d.instant_game D/WebSocket.cpp: WebSocket (0x9320da80) Unhandled websocket event: 33
2019-01-28 11:23:27.257 26127-26168/org.cocos2d.instant_game D/WebSocket.cpp: WebSocket (0x9320da80) onConnectionError, state: 0 ...
2019-01-28 11:23:27.257 26127-26168/org.cocos2d.instant_game D/WebSocket.cpp: WebSocket (0x9320da80) onConnectionClosed, state: 2 ...
2019-01-28 11:23:27.257 26127-26168/org.cocos2d.instant_game D/WebSocket.cpp: onConnectionClosed, WebSocket (0x9320da80) is closing by server.
2019-01-28 11:23:27.257 26127-26168/org.cocos2d.instant_game D/WebSocket.cpp: WebSocket (0x9320da80) onConnectionClosed DONE!
2019-01-28 11:23:27.257 26127-26168/org.cocos2d.instant_game D/WebSocket.cpp: WebSocket (0x9320da80) onConnectionClosed, state: 3 ...
2019-01-28 11:23:27.257 26127-26168/org.cocos2d.instant_game D/WebSocket.cpp: WebSocket (0x9320da80) onConnectionError, state: 3 ...
2019-01-28 11:23:27.565 1678-2521/? D/NetworkMonitor/NetworkAgentInfo [WIFI () - 101]: PROBE_FALLBACK http://www.google.com/gen_204 Probably not a portal: exception java.net.SocketTimeoutException: failed to connect to www.google.com/2404:6800:4008:800::2004 (port 80) from /fec0::d089:e460:b955:1894 (port 45852) after 10000ms
2019-01-28 11:23:27.567 1678-1762/? D/WifiStateMachine: NETWORK_STATUS_UNWANTED_VALIDATION_FAILED
2019-01-28 11:23:29.864 1678-1695/? E/memtrack: Couldn't load memtrack module
2019-01-28 11:23:29.864 1678-1695/? W/android.os.Debug: failed to get memory consumption info: -1
This is cocos websocket implementation code
According to the error log ERR: ERROR on binding fd 58 to port 0 (-1 13)
, it means 'permission denied'. Does this mean I could not use libwebsockets in Android Instant App environment?