Skip to content

Commit c4b2066

Browse files
Neplexgabber235
authored andcommitted
fix: force default WebSocket port to prevent :0 error when port is missing
1 parent 1d6d3c3 commit c4b2066

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/lib/models/communicator.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ class SocketNotifier extends StateNotifier<Socket?> {
112112
return;
113113
}
114114

115-
var url = secure ? "wss://$hostname" : "ws://$hostname";
116-
if (port != null) url += ":$port";
115+
var socketPort = (port == null || port == 0) ? (secure ? 443 : 80) : port;
116+
var scheme = secure ? "wss" : "ws";
117+
var url = "$scheme://$hostname:$socketPort";
117118
if (token != null) url += "?token=$token";
118119

119120
debugPrint("Initializing socket to $url");

0 commit comments

Comments
 (0)