-
Notifications
You must be signed in to change notification settings - Fork 10
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
Random port used #36
Comments
I get the same error. Did you manage to get around it? |
How are you running your app (iOS/Android/Web/Desktop etc) |
tl;dr - this is not a bug, the port number you are seeing in the exception is the local port, not the remote port you are trying to connect to. This exception means that Flutter could not connect to remote devtools. Either remotedev is not running, or is not listening on port 8000, or is on a different IP address, or there is some other networking issue preventing Flutter from connecting. To help debug this further I really need to know the platform you're running Flutter on (web, iOS, Android), whether you are running on a device or a simulator, and possibly a bit more about your local network. Longer explanation OK, so this is not actually a bug, just a confusing error message coming from WebSocket.connect, as used inside socketcluster. That port number you are seeing is the local port allocated to Flutter by the OS, not the remote port you are attempting to connect to. When any TCP connection is initiated, the operating system opens up a random port on the local device (in this case, the device the Flutter app is running on). This local port is how data gets from the remote host back to your app. And so the connection might end up being from I'm not sure why the WebSocket exception is showing the local port in the exception rather than the remote one, it does seem confusing. However, you can see the connection attempt being made correctly by stepping through the connect code in the debugger`. You can see the Uri being correctly parsed from socketcluster client: This is then converted into an HTTP URI that can be given to the HttpClient to initiate the connection: The connection at this point should succeed. If it isn't successful you get that exception with the confusing port number. But the connection attempt is correct. A non-exhaustive list of why it might fail to connect:
As I said at the top, I really need more information to help here, but as it stands this is not a bug. |
Hey again, thanks for the brief explanation, I re-inserted these tools, and out of nowhere it worked correctly, I must have forgotten something in the code or missed something, I honestly don't know. But the point is, it is working correctly. Where I am testing is on Flutter on the mobile platform, currently Android with the "RemoteDev" server on Windows 11. With the following execution code: void main() {
runApp(const ExampleApp());
}
class ExampleApp extends StatefulWidget {
const ExampleApp({Key? key}) : super(key: key);
@override
_ExampleAppState createState() => _ExampleAppState();
}
class _ExampleAppState extends State<ExampleApp> {
late DevToolsStore<AppState> store;
@override
void initState() {
super.initState();
final RemoteDevToolsMiddleware<AppState> remoteDevtools = RemoteDevToolsMiddleware<AppState>('192.168.1.71:8000');
store = DevToolsStore<AppState>(
<Reducer>,
initialState: <Initial State>,
middleware: [
<Others Middlewares>,
remoteDevtools,
]
);
remoteDevtools.store = store;
remoteDevtools.connect();
}
@override
Widget build(BuildContext context) {
}
} |
In my previous message, I forgot to mention that the tests are produced in the emulator and not on a physical/real device. It was as I was saying, before I was trying on a physical/real device and nothing worked correctly, so now I was doing these tests and they are not working at all even using a local IP from the Wi-Fi network, no effects. Do you have any idea what it could be? |
Just came across this issue. For anyone who is still struggling with this, I've got remote devtools working on an emulator. Since the Android emulator maps |
Hi,
I tried the example as mentionned on pub.dev but the app runs in timeout because it cannot connect to remote devtools and the used port is not the one I provided. Is this normal?
Thank you
The text was updated successfully, but these errors were encountered: