Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket Disconnection issue on Specific Mobile Network on JIO 5g network in INDIA #4891

Open
Nilesh410451 opened this issue Dec 7, 2023 · 11 comments
Labels
question Further information is requested

Comments

@Nilesh410451
Copy link

Socket.io Version 4.7.2 in NODEJS

Best http socket.io client Version 2.8.6

Platform we are using Unity3d 2021.3.27f1

image_2023_12_07T07_07_20_779Z

Hi Team,

we are using above version for creating socket connection for our game.

The socket is working fine on all other mobile networks and WIFI except JIO 5G network in INDIA.

Once we connect the socket using JIO 5G network. The socket get disconnected multiple times without any reason and this is happens only on JIO 5G Network.

Please let us know how to resolve it

ERROR 1

Error in socket = {"message":"Request Finished with Error! Exception: Unable to read data from the transport connection: Connection reset by peer. at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x000ac] in <160ff2a7112f4c5e8071e4724342c6b6>:0 \n at BestHTTP.Extensions.ReadOnlyBufferedStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x00069] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/Extensions/ReadOnlyBufferedStream.cs:48 \n at BestHTTP.Connections.BufferedReadNetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00000] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/Connections/BufferedReadNetworkStream.cs:70 \n at BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.RecordStream+Record.FillTo (System.IO.Stream input, System.Int32 length) [0x00002] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/SecureProtocol/tls/RecordStream.cs:495 \n at BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.RecordStream+Record.ReadHeader (System.IO.Stream input) [0x00000] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/SecureProtocol/tls/RecordStream.cs:533 \n at BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.RecordStream.ReadRecord () [0x00000] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/SecureProtocol/tls/RecordStream.cs:207 \n at BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.TlsProtocol.SafeReadRecord () [0x00060] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/SecureProtocol/tls/TlsProtocol.cs:887 \n at BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.TlsProtocol.ReadApplicationData (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x0004f] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/SecureProtocol/tls/TlsProtocol.cs:748 \n at BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.TlsStream.ReadByte () [0x00000] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/SecureProtocol/tls/TlsStream.cs:76 \n at BestHTTP.WebSocket.Frames.WebSocketFrameReader.ReadByte (System.IO.Stream stream) [0x00000] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/WebSocket/Frames/WebSocketFrameReader.cs:128 \n at BestHTTP.WebSocket.Frames.WebSocketFrameReader.Read (System.IO.Stream stream) [0x00000] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/WebSocket/Frames/WebSocketFrameReader.cs:50 \n at BestHTTP.WebSocket.WebSocketResponse.ReceiveThreadFunc () [0x00018] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/WebSocket/WebSocketResponse.cs:408 "}

UnityEngine.Debug:LogError (object)

Carrom365.SocketController/<>c:b__38_2 (object) (at Assets/LUDO/Scripts/Common/SocketController.cs:219)

BestHTTP.SocketIO3.Socket/<>c__DisplayClass36_0`1:b__0 (object[]) (at Assets/ThirdPartyPlugins/Best HTTP/Source/SocketIO.3/Socket.cs:243)

BestHTTP.SocketIO3.Events.TypedEventTable:Call (string,object[]) (at Assets/ThirdPartyPlugins/Best HTTP/Source/SocketIO.3/Events/TypedEventTable.cs:95)

BestHTTP.SocketIO3.Socket:BestHTTP.SocketIO3.ISocket.EmitEvent (string,object[]) (at Assets/ThirdPartyPlugins/Best HTTP/Source/SocketIO.3/Socket.cs:483)

BestHTTP.SocketIO3.SocketManager:BestHTTP.SocketIO3.IManager.EmitEvent (string,object[]) (at Assets/ThirdPartyPlugins/Best HTTP/Source/SocketIO.3/SocketManager.cs:642)

BestHTTP.SocketIO3.SocketManager:BestHTTP.SocketIO3.IManager.EmitEvent (BestHTTP.SocketIO3.SocketIOEventTypes,object[]) (at Assets/ThirdPartyPlugins/Best HTTP/Source/SocketIO.3/SocketManager.cs:650)

BestHTTP.SocketIO3.SocketManager:BestHTTP.SocketIO3.IManager.EmitError (string) (at Assets/ThirdPartyPlugins/Best HTTP/Source/SocketIO.3/SocketManager.cs:662)

BestHTTP.SocketIO3.SocketManager:BestHTTP.SocketIO3.IManager.OnTransportError (BestHTTP.SocketIO3.Transports.ITransport,string) (at Assets/ThirdPartyPlugins/Best HTTP/Source/SocketIO.3/SocketManager.cs:483)

BestHTTP.SocketIO3.Transports.WebSocketTransport:OnError (BestHTTP.WebSocket.WebSocket,string) (at Assets/ThirdPartyPlugins/Best HTTP/Source/SocketIO.3/Transports/WebSocketTransport.cs:261)

BestHTTP.WebSocket.OverHTTP1:OnInternalRequestCallback (BestHTTP.HTTPRequest,BestHTTP.HTTPResponse) (at Assets/ThirdPartyPlugins/Best HTTP/Source/WebSocket/Implementations/OverHTTP1.cs:206)

BestHTTP.Core.RequestEventHelper:HandleRequestStateChange (BestHTTP.Core.RequestEventInfo) (at Assets/ThirdPartyPlugins/Best HTTP/Source/Core/RequestEvents.cs:569)

BestHTTP.Core.RequestEventHelper:ProcessQueue () (at Assets/ThirdPartyPlugins/Best HTTP/Source/Core/RequestEvents.cs:437)

BestHTTP.HTTPManager:OnUpdate () (at Assets/ThirdPartyPlugins/Best HTTP/Source/HTTPManager.cs:422)

BestHTTP.HTTPUpdateDelegator:CallOnUpdate () (at Assets/ThirdPartyPlugins/Best HTTP/Source/HTTPUpdateDelegator.cs:286)

BestHTTP.HTTPUpdateDelegator:Update () (at Assets/ThirdPartyPlugins/Best HTTP/Source/HTTPUpdateDelegator.cs:276

ERROR 2

Error in socket = {"message":"[BestHTTP.Connections.HTTP1Handler] Remote server closed the connection before sending response header! Previous request state: Processing. Connection state: Processing\n"}

UnityEngine.Debug:LogError (object)

ERROR 3

Error in socket = {"message":"Unable to write data to the transport connection: The socket has been shut down.\n at BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.TlsProtocol.SafeWriteRecord (System.Int16 type, System.Byte[] buf, System.Int32 offset, System.Int32 len) [0x00036] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/SecureProtocol/tls/TlsProtocol.cs:939 \n at BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.TlsProtocol.WriteApplicationData (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x000e5] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/SecureProtocol/tls/TlsProtocol.cs:1060 \n at BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.TlsStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00000] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/SecureProtocol/tls/TlsStream.cs:92 \n at BestHTTP.Extensions.WriteOnlyBufferedStream.Flush () [0x00009] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/Extensions/WriteOnlyBufferedStream.cs:35 \n at BestHTTP.HTTPRequest.SendOutTo (System.IO.Stream stream) [0x000b3] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/HTTPRequest.cs:1255 \n at BestHTTP.Connections.HTTP1Handler.RunHandler () [0x000b7] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/Connections/HTTP1Handler.cs:61 "}

@Nilesh410451 Nilesh410451 added the to triage Waiting to be triaged by a member of the team label Dec 7, 2023
@Nilesh410451
Copy link
Author

Anyone have idea...about socket disconnection issue. 534 million users are using JIO 5G network and its major issue. Need to resolve it ASAP..its critical issue in socket.io

@darrachequesne
Copy link
Member

It seems that there is an issue with the WebSocket connection. Not sure what we can do to prevent this though.

Does it also happen with HTTP long-polling only?

const socket = io("https://example.com", {
  transports: ["polling"]
});

@darrachequesne darrachequesne added question Further information is requested and removed to triage Waiting to be triaged by a member of the team labels Dec 8, 2023
@Nilesh410451
Copy link
Author

Nilesh410451 commented Dec 8, 2023 via email

@Nilesh410451
Copy link
Author

Hi Team,
This issue is not resolved yet. We are using below code but the same issue appears again.

const socket = io("https://example.com", {
transports: ["polling"]
});

I have emailed to the network operator but they have not resolved the issue.
Please check below error logs.

Error in socket = {"message":"Request Finished with Error! Exception: Unable to read data from the transport connection: Connection reset by peer. at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x000ac] in <160ff2a7112f4c5e8071e4724342c6b6>:0 \n at BestHTTP.Extensions.ReadOnlyBufferedStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x00069] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/Extensions/ReadOnlyBufferedStream.cs:48 \n at BestHTTP.Connections.BufferedReadNetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00000] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/Connections/BufferedReadNetworkStream.cs:70 \n at BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.RecordStream+Record.FillTo (System.IO.Stream input, System.Int32 length) [0x00002] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/SecureProtocol/tls/RecordStream.cs:495 \n at BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.RecordStream+Record.ReadHeader (System.IO.Stream input) [0x00000] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/SecureProtocol/tls/RecordStream.cs:533 \n at BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.RecordStream.ReadRecord () [0x00000] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/SecureProtocol/tls/RecordStream.cs:207 \n at BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.TlsProtocol.SafeReadRecord () [0x00060] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/SecureProtocol/tls/TlsProtocol.cs:887 \n at BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.TlsProtocol.ReadApplicationData (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x0004f] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/SecureProtocol/tls/TlsProtocol.cs:748 \n at BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.TlsStream.ReadByte () [0x00000] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/SecureProtocol/tls/TlsStream.cs:76 \n at BestHTTP.WebSocket.Frames.WebSocketFrameReader.ReadByte (System.IO.Stream stream) [0x00000] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/WebSocket/Frames/WebSocketFrameReader.cs:128 \n at BestHTTP.WebSocket.Frames.WebSocketFrameReader.Read (System.IO.Stream stream) [0x00000] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/WebSocket/Frames/WebSocketFrameReader.cs:50 \n at BestHTTP.WebSocket.WebSocketResponse.ReceiveThreadFunc () [0x00018] in /Users/aaryanshgawade/Carrom365Android/Assets/ThirdPartyPlugins/Best HTTP/Source/WebSocket/WebSocketResponse.cs:408 "}
UnityEngine.Debug:LogError (object)
Carrom365.SocketController/<>c:b__38_2 (object) (at Assets/LUDO/Scripts/Common/SocketController.cs:230)
BestHTTP.SocketIO3.Socket/<>c__DisplayClass36_0`1:b__0 (object[]) (at Assets/ThirdPartyPlugins/Best HTTP/Source/SocketIO.3/Socket.cs:243)
BestHTTP.SocketIO3.Events.TypedEventTable:Call (string,object[]) (at Assets/ThirdPartyPlugins/Best HTTP/Source/SocketIO.3/Events/TypedEventTable.cs:95)
BestHTTP.SocketIO3.Socket:BestHTTP.SocketIO3.ISocket.EmitEvent (string,object[]) (at Assets/ThirdPartyPlugins/Best HTTP/Source/SocketIO.3/Socket.cs:483)
BestHTTP.SocketIO3.SocketManager:BestHTTP.SocketIO3.IManager.EmitEvent (string,object[]) (at Assets/ThirdPartyPlugins/Best HTTP/Source/SocketIO.3/SocketManager.cs:642)
BestHTTP.SocketIO3.SocketManager:BestHTTP.SocketIO3.IManager.EmitEvent (BestHTTP.SocketIO3.SocketIOEventTypes,object[]) (at Assets/ThirdPartyPlugins/Best HTTP/Source/SocketIO.3/SocketManager.cs:650)
BestHTTP.SocketIO3.SocketManager:BestHTTP.SocketIO3.IManager.EmitError (string) (at Assets/ThirdPartyPlugins/Best HTTP/Source/SocketIO.3/SocketManager.cs:662)
BestHTTP.SocketIO3.SocketManager:BestHTTP.SocketIO3.IManager.OnTransportError (BestHTTP.SocketIO3.Transports.ITransport,string) (at Assets/ThirdPartyPlugins/Best HTTP/Source/SocketIO.3/SocketManager.cs:483)
BestHTTP.SocketIO3.Transports.WebSocketTransport:OnError (BestHTTP.WebSocket.WebSocket,string) (at Assets/ThirdPartyPlugins/Best HTTP/Source/SocketIO.3/Transports/WebSocketTransport.cs:261)
BestHTTP.WebSocket.OverHTTP1:OnInternalRequestCallback (BestHTTP.HTTPRequest,BestHTTP.HTTPResponse) (at Assets/ThirdPartyPlugins/Best HTTP/Source/WebSocket/Implementations/OverHTTP1.cs:206)
BestHTTP.Core.RequestEventHelper:HandleRequestStateChange (BestHTTP.Core.RequestEventInfo) (at Assets/ThirdPartyPlugins/Best HTTP/Source/Core/RequestEvents.cs:569)
BestHTTP.Core.RequestEventHelper:ProcessQueue () (at Assets/ThirdPartyPlugins/Best HTTP/Source/Core/RequestEvents.cs:437)
BestHTTP.HTTPManager:OnUpdate () (at Assets/ThirdPartyPlugins/Best HTTP/Source/HTTPManager.cs:422)
BestHTTP.HTTPUpdateDelegator:CallOnUpdate () (at Assets/ThirdPartyPlugins/Best HTTP/Source/HTTPUpdateDelegator.cs:286)
BestHTTP.HTTPUpdateDelegator:Update () (at Assets/ThirdPartyPlugins/Best HTTP/Source/HTTPUpdateDelegator.cs:276)

@Nilesh410451
Copy link
Author

Nilesh410451 commented Dec 11, 2023 via email

@darrachequesne
Copy link
Member

If the ISP is closing the TCP connection, I don't think there is much we can do (besides reconnecting, which should already be the case).

@Nilesh410451
Copy link
Author

Nilesh410451 commented Dec 11, 2023 via email

@Nilesh410451
Copy link
Author

Nilesh410451 commented Dec 11, 2023 via email

@nishantmovaliya
Copy link

nishantmovaliya commented Feb 14, 2024

const SocketIo = require('socket.io');
const io = SocketIo(server, {
allowUpgrades: false
});

Hi @Nilesh410451, I have used above solution at server side, its works fine in my case.
if you have still problem and you are passing huge payload
you can increase { "pingTimeout: 60000" } by passing this parameter and also change value according your requirement.

@itsji10dra
Copy link

@Nilesh410451 Hi there, I am facing the same issue on my flutter app using official plugin websocket_channel. My connection abrupt with close code 1002 (details here). After struggling bw my backend and frontend for over a week I have noticed this in other apps as well. It only happens when I am on mobile network not on Wifi. This is indeed a JIO's issue and nothing to do with the libraries we are using. Same issue is observed by me while playing chess on my phone on chess.com app, similar to what you have shared with Carrom app. I do not see any solution here, other than improving our services. If you can across some better alternative/solution please connect with me.

@Mpratyush54
Copy link

You should consider using a network monitoring tool to find the error better that why the connection is reset by the peer.
Also you can try that there is a min delay between 2 consecutive requests. consider reading this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants