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 connecting infinitely. + https not connecting #3

Closed
faiziakbr opened this issue Jan 11, 2019 · 25 comments
Closed

Socket connecting infinitely. + https not connecting #3

faiziakbr opened this issue Jan 11, 2019 · 25 comments
Assignees
Labels
bug Something isn't working

Comments

@faiziakbr
Copy link

I have implemented the adhara socket.
i have successfully emitted and received the message from server side but the problem is the socket is again connecting and sending the request indefinitely.
how to stop this?

@tiholic
Copy link
Contributor

tiholic commented Jan 12, 2019

@faiziakbr can you share the code?

@tiholic tiholic self-assigned this Jan 12, 2019
@tiholic tiholic added the awaiting response Waiting for issue owner's response label Jan 12, 2019
@faiziakbr
Copy link
Author

faiziakbr commented Jan 12, 2019

Here is the code.

SocketIO socket = await SocketIOManager().createInstance('http://URL:8000/');
    socket.onConnect((data){
      print("connected...");
      print(data);
      socket.emit("upDownVoteRequest", ['Hello World']);
    });
    socket.on("upDownVoteResponse", (data){   //sample event
      print("news");
      print(data);
    });
    socket.connect();

@tiholic tiholic removed the awaiting response Waiting for issue owner's response label Jan 12, 2019
@tiholic
Copy link
Contributor

tiholic commented Jan 16, 2019

@faiziakbr

can you upgrade to latest (0.1.8) and create a socketIO instance using the below code and share the logs here?

SocketIOManager manager = SocketIOManager();
socket = await manager.createInstance(
    YOUR_SERVER_URI,
    enableLogging: true
);

@faiziakbr
Copy link
Author

@tiholic
I have updated to 0.1.8 and enabled the log, but i see no difference in the logs.

D/Adhara:Socket(26850): Connecting to... http://BASE_URL:8000/
D/Adhara:Socket(26850): registering::connect
D/Adhara:Socket(26850): registering::upDownVoteResponse
D/Adhara:Socket(26850): Connecting....
D/Adhara:Socket(26850): Socket triggered::connect
D/Adhara:Socket(26850): emitting:::[{"discount":"5b28e383bc77de7ffcd75c29","customer":"5b09162319c9060d7c79f52f","isUpVote":false,"isDownVote":true}]:::to:::upDownVoteRequest
I/System.out(26850): {"discount":"5b28e383bc77de7ffcd75c29","customer":"5b09162319c9060d7c79f52f","isUpVote":false,"isDownVote":true}
I/System.out(26850): class java.lang.String
D/Adhara:Socket(26850): Socket triggered::upDownVoteResponse
I/flutter (26850): news
I/flutter (26850): {status: false, msg: customer not found}
D/Adhara:Socket(26850): un-registering:::upDownVoteResponse
D/Adhara:Socket(26850): un-registering:::upDownVoteRequest
I/zygote  (26850): Do partial code cache collection, code=30KB, data=24KB
I/zygote  (26850): After code cache collection, code=30KB, data=24KB
I/zygote  (26850): Increasing code cache capacity to 128KB
D/Adhara:Socket(26850): Socket triggered::reconnect
D/Adhara:Socket(26850): Socket triggered::connect
D/Adhara:Socket(26850): Socket triggered::connect
D/Adhara:Socket(26850): emitting:::[{"discount":"5b28e383bc77de7ffcd75c29","customer":"5b09162319c9060d7c79f52f","isUpVote":false,"isDownVote":true}]:::to:::upDownVoteRequest
I/System.out(26850): {"discount":"5b28e383bc77de7ffcd75c29","customer":"5b09162319c9060d7c79f52f","isUpVote":false,"isDownVote":true}
I/System.out(26850): class java.lang.String
D/Adhara:Socket(26850): Socket triggered::reconnect
D/Adhara:Socket(26850): Socket triggered::connect
D/Adhara:Socket(26850): Socket triggered::connect
D/Adhara:Socket(26850): emitting:::[{"discount":"5b28e383bc77de7ffcd75c29","customer":"5b09162319c9060d7c79f52f","isUpVote":false,"isDownVote":true}]:::to:::upDownVoteRequest
I/System.out(26850): {"discount":"5b28e383bc77de7ffcd75c29","customer":"5b09162319c9060d7c79f52f","isUpVote":false,"isDownVote":true}
I/System.out(26850): class java.lang.String
D/Adhara:Socket(26850): Socket triggered::reconnect
D/Adhara:Socket(26850): Socket triggered::connect
D/Adhara:Socket(26850): Socket triggered::connect
D/Adhara:Socket(26850): emitting:::[{"discount":"5b28e383bc77de7ffcd75c29","customer":"5b09162319c9060d7c79f52f","isUpVote":false,"isDownVote":true}]:::to:::upDownVoteRequest
I/System.out(26850): {"discount":"5b28e383bc77de7ffcd75c29","customer":"5b09162319c9060d7c79f52f","isUpVote":false,"isDownVote":true}
I/System.out(26850): class java.lang.String

@tiholic tiholic added the bug Something isn't working label Jan 20, 2019
@mickaeldamatha
Copy link

mickaeldamatha commented Feb 1, 2019

Hello, I'am sorry but I have approximately the same problem. here my console log and my code attached:

Syncing files to device Android SDK built for x86...
Restarted application in 4 785ms.
I/flutter (30107): initSockets.......
D/Adhara:Socket(30107): Connecting to... http://localhost:3000/
D/Adhara:Socket(30107): registering::connect
D/Adhara:Socket(30107): registering::top_events
D/Adhara:Socket(30107): registering::disconnect
D/Adhara:Socket(30107): registering::reconnect
D/Adhara:Socket(30107): Connecting....

capture d ecran 2019-02-01 a 14 50 09

Can you help me please...the app stay blocked on "connecting..."

@tiholic
Copy link
Contributor

tiholic commented Feb 2, 2019

@mickadam87 I'm working on a fix. Will update soon.

@mickaeldamatha
Copy link

mickaeldamatha commented Feb 4, 2019

I have found the problem. I have to use "http://10.0.2.2:3000" in place of "localhost:3000" in Android Virtual Device ! Socket connected ! Thank you so much !

For informations : https://developer.android.com/studio/run/emulator-networking

@mickaeldamatha
Copy link

Sorry, but I have a new issue during Xcode Building...

PATHto MYapp/ios/Pods/Socket.IO-Client-Swift/Source/SocketIO/Engine/SocketEngine.swift:316:11: error: value of type 'WebSocket' has no member 'onHttpResponseHeaders'

Known issue ?

@tiholic
Copy link
Contributor

tiholic commented Feb 8, 2019

@mickadam87 yes.

#8

@choecode
Copy link

I'am sorry but I have approximately the same problem

D/Adhara:Socket(19495): Socket triggered::reconnect I/flutter (19495): reconnected to socket.io D/Adhara:Socket(19495): Socket triggered::connect D/Adhara:Socket(19495): emitting:::null:::to:::GroupJoin I/flutter (19495): connected... D/Adhara:Socket(19495): Socket triggered::disconnect I/flutter (19495): disconnected from socket.io D/Adhara:Socket(19495): Socket triggered::reconnect I/flutter (19495): reconnected to socket.io D/Adhara:Socket(19495): Socket triggered::connect I/flutter (19495): connected... D/Adhara:Socket(19495): emitting:::null:::to:::GroupJoin D/Adhara:Socket(19495): Socket triggered::disconnect I/flutter (19495): disconnected from socket.io D/Adhara:Socket(19495): Socket triggered::reconnect I/flutter (19495): reconnected to socket.io D/Adhara:Socket(19495): Socket triggered::connect I/flutter (19495): connected... D/Adhara:Socket(19495): emitting:::null:::to:::GroupJoin D/Adhara:Socket(19495): Socket triggered::disconnect I/flutter (19495): disconnected from socket.io D/Adhara:Socket(19495): Socket triggered::reconnect I/flutter (19495): reconnected to socket.io D/Adhara:Socket(19495): Socket triggered::connect D/Adhara:Socket(19495): emitting:::null:::to:::GroupJoin I/flutter (19495): connected...

@choecode
Copy link

i have try to clone the example project and changed the url to my own host.the problem still happend.

@majoferenc
Copy link

majoferenc commented Apr 27, 2019

For me in the latest version it is working flawlessly on Android side, but iOS is connecting infinitely...
EDIT: I've added to ios/Runner/info.plist this and now it works on iOS too.

<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>

@theromie
Copy link

I am facing same issue due to this message screen is getting refreshed and load content again

@mucan54
Copy link

mucan54 commented Oct 3, 2019

In socket.io this problem happened to me when the server's socket.io version and client's socket.io version was different.

@agnoam
Copy link

agnoam commented Oct 29, 2019

Hey, what is the status of this problem ?
Are you still working on this ?

@Jasper-zzq
Copy link

I encountered the same problem. I don’t see it when I visit the local.

@saarangtiwari
Copy link

@tiholic Hi, have you fixed the issue?
In my current scenario, I am able to connect to the socketIO server which we have on staging but not the one on production using iOS. Let me know if you require any inputs from my end like code snippets.

@oncleguigs
Copy link

Same issue here, did someone found a fix ?

@saarangtiwari
Copy link

After too many trials and failures, I have finally written a solution in Javascript until we have a working solution for Flutter. I am writing a blog about it and will share the solution there with a complete explanation. I will add the link here for reference as soon as possible.

@saarangtiwari
Copy link

@oncleguigs @Jasper-zzq @agnoam
I have come up with a solution using javascript. Please read my blog for the complete solution:
https://saarangtiwari.com/blog/how-i-used-javascript-to-bridge-and-connect-to-websockets-in-flutter

@tiholic tiholic changed the title Socket connecting infinitely. Socket connecting infinitely. + https not connecting May 23, 2020
@SankhaJay
Copy link

hey guys
try adding inside the android/app/src/main/AndroidManifest.xml file this
<application
....
....
android:usesCleartextTraffic="true">

@Atuldubey98
Copy link

Hello, I'am sorry but I have approximately the same problem. here my console log and my code attached:

Syncing files to device Android SDK built for x86...
Restarted application in 4 785ms.
I/flutter (30107): initSockets.......
D/Adhara:Socket(30107): Connecting to... http://localhost:3000/
D/Adhara:Socket(30107): registering::connect
D/Adhara:Socket(30107): registering::top_events
D/Adhara:Socket(30107): registering::disconnect
D/Adhara:Socket(30107): registering::reconnect
D/Adhara:Socket(30107): Connecting....

capture d ecran 2019-02-01 a 14 50 09

Can you help me please...the app stay blocked on "connecting..."

Was this problem solved?? Connecting of socket infinite no of times and then disconnecting.

@mannnish
Copy link

it's 2021 and i am still facing the exact same issue.

@yusufnadar
Copy link

Any solution?

@tiholic
Copy link
Contributor

tiholic commented Apr 6, 2021

Please try using new release: V1.0.0 and create a new issue if any problem still exists.

Note that the this package currently supports only socket.io v2. Track status for v3/v4 socket here: #160

@yusufnadar @mannnish @Atuldubey98 @SankhaJay @saarang1995 @oncleguigs @Jasper-zzq @agnoam @mucan54 @theromie @majoferenc @choecode @mickadam87 @faiziakbr

@tiholic tiholic closed this as completed Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests