Skip to content

Commit

Permalink
fix: Adds a quick fix for the iOS sync issue after suspend (#2414)
Browse files Browse the repository at this point in the history
iOS appears to not be syncing correctly after resuming from suspend.
It looks like this is due to the libp2p auto-dialler getting stuck
connecting to the Tor HTTP tunnel port which is replaced after
suspend/resume. This commit enables the WebsocketOverTor transport to
use the `dialTimeout` correctly. But still this means the current
dialer waits for `dialTimeout` to try another peer, and we currently
have `dialTimeout` set to 2 minutes. Ideally, we can find a better
approach for closing any sockets when suspending the app or detecting
when we are trying to connect to a port that nothing is listening on,
if that's possible.
  • Loading branch information
leblowl committed Apr 10, 2024
1 parent fa3a9b6 commit 151895d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/backend/src/nest/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ export class AppModule {
io.engine.use((req, res, next) => {
const authHeader = req.headers['authorization']
if (!authHeader) {
console.error('No authorization header')
console.error('Backend server: No authorization header')
res.writeHead(401, 'No authorization header')
res.end()
return
}

const token = authHeader && authHeader.split(' ')[1]
if (!token) {
console.error('No auth token')
console.error('Backend server: No auth token')
res.writeHead(401, 'No authorization token')
res.end()
return
Expand All @@ -122,7 +122,7 @@ export class AppModule {
if (verifyToken(options.socketIOSecret, token)) {
next()
} else {
console.error('Wrong basic token')
console.error('Backend server: Unauthorized')
res.writeHead(401, 'Unauthorized')
res.end()
}
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/nest/websocketOverTor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class WebSockets extends EventEmitter {
websocket: {
...this._websocketOpts,
},
signal: options.signal,
})
} catch (e) {
log.error('error connecting to %s. Details: %s', ma, e.message)
Expand Down
1 change: 0 additions & 1 deletion packages/mobile/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ function App(): JSX.Element {
ref={navigationRef}
linking={linking}
onReady={() => {
dispatch(initActions.blindWebsocketConnection())
dispatch(navigationActions.redirection())
}}
>
Expand Down

0 comments on commit 151895d

Please sign in to comment.