File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -15,9 +15,13 @@ import { getErrorCode } from '../lib/error.js'
15
15
/** @typedef {{ publicKey: Buffer, secretKey: Buffer } } Keypair */
16
16
/** @typedef {OpenedNoiseStream<net.Socket> } OpenedNetNoiseStream */
17
17
18
+ /** @satisfies {import('node:net').ServerOpts | import('node:net').TcpNetConnectOpts } */
18
19
const TCP_KEEP_ALIVE_OPTIONS = {
19
20
keepAlive : true ,
20
21
keepAliveInitialDelay : 30_000 ,
22
+ // Turn off Nagle's algorythm, to reduce latency
23
+ // https://github.com/digidem/comapeo-core/issues/1070
24
+ noDelay : true ,
21
25
}
22
26
export const ERR_DUPLICATE = 'Duplicate connection'
23
27
@@ -108,9 +112,9 @@ export class LocalDiscovery extends TypedEmitter {
108
112
return
109
113
}
110
114
const socket = net . connect ( {
115
+ ...TCP_KEEP_ALIVE_OPTIONS ,
111
116
host : address ,
112
117
port,
113
- ...TCP_KEEP_ALIVE_OPTIONS ,
114
118
} )
115
119
socket . on ( 'error' , this . #handleSocketError)
116
120
socket . once ( 'connect' , ( ) => {
You can’t perform that action at this time.
0 commit comments