socket.io-client-dart
socket.io-client-dart copied to clipboard
Port number 0 is added to url automatically
Why it is adding port number zero at the end of url automatically ? How can i remove the port number. I want to run it without port number.
same problem
@jumperchen can you please have a look at it? Here are the details.
-
client :
^2.0.0-beta.4-nullsafety.0
-
platform :
flutter web
-
server :
version 3.1.2
Here is the code.
import 'package:socket_io_client/socket_io_client.dart' as IO;
IO.Socket socket = IO.io(
'wss://socket.example.com',
IO.OptionBuilder()
.setTransports(['websocket'])
.build());
With the above code, the URL becomes: wss://socket.example.com:0/socket.io/?EIO=4&transport=websocket
:0
after socket.example.com
I think the issue is with the file socket_io_client.dart:49. If no port is passed then due to null safety it takes default int value 0
.
Solution:
For those who are looking solution for it, pass a port number while connecting. If no custom port by server, for ws
pass 80
for wss
pass 443
. Example:
import 'package:socket_io_client/socket_io_client.dart' as IO;
IO.Socket socket = IO.io(
'wss://socket.example.com:443',
IO.OptionBuilder()
.setTransports(['websocket'])
.build());
Same issue
@neeraj-htp thanks for the support. Some of are connecting to services that cannot expose port numbers unfortunately. This is a quick fix via a PR.
@neeraj-htp This doesn't seem to solve the issue. Having the same issue on android device, even after mentioning the port number in the url.
Any one get the solution?
@Hassan6197 you had to set the port number, usually providers like Google Cloud use 443 as the default for this type of traffic.