From 42c4bfcb47617cc8cf4448213bbcc4b74951a148 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Tue, 15 Jun 2021 06:27:32 -0700 Subject: [PATCH] Better error for ports in use Summary: If port 8088 / 8089 are in use, devices will not be able to connect to Flipper. We have checks for this in place, however it turns out that users can miss them. Potentially this can be caused for mulltiple reasons: 1. The notification is shown fairly short (in my testing it disappeared sometimes in < 2 secs 2. The notification is shown outside of the Flipper area 3. Flipper might not have permissions to show notifs in the first place. Changed the notification to show inside Flipper, not hide automatically, and added clearer instructions. Including mentioning the port number (since there are multiple) Changelog: [Flipper] Provide clearer error if Flipper ports are already in use, making device connections impossible Differential Revision: D29128014 fbshipit-source-id: 16d9b451aa84281744155bfa1042429911a7b774 --- desktop/app/src/dispatcher/server.tsx | 31 +++++++++++++++++++-------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/desktop/app/src/dispatcher/server.tsx b/desktop/app/src/dispatcher/server.tsx index 7be1654eb..a17384500 100644 --- a/desktop/app/src/dispatcher/server.tsx +++ b/desktop/app/src/dispatcher/server.tsx @@ -18,7 +18,7 @@ import {CertificateExchangeMedium} from '../utils/CertificateProvider'; import {selectClient, selectDevice} from '../reducers/connections'; import {isLoggedIn} from '../fb-stubs/user'; import React from 'react'; -import {Typography} from 'antd'; +import {notification, Typography} from 'antd'; import {ACTIVE_SHEET_SIGN_IN, setActiveSheet} from '../reducers/application'; export default (store: Store, logger: Logger) => { @@ -30,14 +30,27 @@ export default (store: Store, logger: Logger) => { }); server.addListener('error', (err) => { - store.dispatch( - addErrorNotification( - 'Failed to start websocket server', - err.code === 'EADDRINUSE' - ? "Couldn't start websocket server. Looks like you have multiple copies of Flipper running." - : err.message || 'Unknown error', - ), - ); + notification.error({ + message: 'Failed to start connection server', + description: + err.code === 'EADDRINUSE' ? ( + <> + Couldn't start connection server. Looks like you have multiple + copies of Flipper running or another process is using the same + port(s). As a result devices will not be able to connect to Flipper. +
+
+ Please try to kill the offending process by running{' '} + kill $(lsof -ti:PORTNUMBER) and restart flipper. +
+
+ {'' + err} + + ) : ( + <>Failed to start connection server: ${err.message} + ), + duration: null, + }); }); server.addListener('start-client-setup', (client: UninitializedClient) => {