@@ -20,21 +20,13 @@ export class HttpStreamTransport extends AbstractTransport {
20
20
private _serverConfig : any ;
21
21
private _serverSetupCallback ?: ( server : McpServer ) => Promise < void > ;
22
22
23
- private _pingInterval ?: NodeJS . Timeout ;
24
- private _pingTimeouts : Map < string | number , NodeJS . Timeout > = new Map ( ) ;
25
- private _pingFrequency : number ;
26
- private _pingTimeout : number ;
27
-
28
23
constructor ( config : HttpStreamTransportConfig = { } ) {
29
24
super ( ) ;
30
25
31
26
this . _port = config . port || 8080 ;
32
27
this . _endpoint = config . endpoint || '/mcp' ;
33
28
this . _enableJsonResponse = config . responseMode === 'batch' ;
34
29
35
- this . _pingFrequency = config . ping ?. frequency ?? 30000 ;
36
- this . _pingTimeout = config . ping ?. timeout ?? 10000 ;
37
-
38
30
logger . debug (
39
31
`HttpStreamTransport configured with: ${ JSON . stringify ( {
40
32
port : this . _port ,
@@ -44,10 +36,6 @@ export class HttpStreamTransport extends AbstractTransport {
44
36
maxMessageSize : config . maxMessageSize ,
45
37
auth : config . auth ? true : false ,
46
38
cors : config . cors ? true : false ,
47
- ping : {
48
- frequency : this . _pingFrequency ,
49
- timeout : this . _pingTimeout ,
50
- } ,
51
39
} ) } `
52
40
) ;
53
41
}
@@ -97,7 +85,6 @@ export class HttpStreamTransport extends AbstractTransport {
97
85
this . _server . listen ( this . _port , ( ) => {
98
86
logger . info ( `HTTP server listening on port ${ this . _port } , endpoint ${ this . _endpoint } ` ) ;
99
87
this . _isRunning = true ;
100
- this . startPingInterval ( ) ;
101
88
resolve ( ) ;
102
89
} ) ;
103
90
} ) ;
@@ -202,52 +189,10 @@ export class HttpStreamTransport extends AbstractTransport {
202
189
) ;
203
190
}
204
191
205
- private startPingInterval ( ) : void {
206
- if ( this . _pingFrequency > 0 ) {
207
- logger . debug (
208
- `Starting ping interval with frequency ${ this . _pingFrequency } ms and timeout ${ this . _pingTimeout } ms`
209
- ) ;
210
- this . _pingInterval = setInterval ( ( ) => this . sendPing ( ) , this . _pingFrequency ) ;
211
- }
212
- }
213
-
214
- private async sendPing ( ) : Promise < void > {
215
- if ( ! this . _isRunning || Object . keys ( this . _transports ) . length === 0 ) {
216
- return ;
217
- }
218
-
219
- const pingId = `ping-${ Date . now ( ) } ` ;
220
- const pingRequest : JSONRPCMessage = {
221
- jsonrpc : '2.0' as const ,
222
- id : pingId ,
223
- method : 'ping' ,
224
- } ;
225
-
226
- logger . debug (
227
- `Broadcasting ping to ${ Object . keys ( this . _transports ) . length } sessions: ${ JSON . stringify ( pingRequest ) } `
228
- ) ;
229
-
230
- for ( const [ sessionId , transport ] of Object . entries ( this . _transports ) ) {
231
- try {
232
- await transport . send ( pingRequest ) ;
233
-
234
- const timeoutId = setTimeout ( ( ) => {
235
- logger . warn ( `Ping timeout for session ${ sessionId } ` ) ;
236
- delete this . _transports [ sessionId ] ;
237
- this . _pingTimeouts . delete ( pingId ) ;
238
- } , this . _pingTimeout ) ;
239
-
240
- this . _pingTimeouts . set ( pingId , timeoutId ) ;
241
- } catch ( error ) {
242
- logger . error ( `Error sending ping to session ${ sessionId } : ${ error } ` ) ;
243
- delete this . _transports [ sessionId ] ;
244
- }
245
- }
246
- }
247
-
248
192
async send ( message : JSONRPCMessage ) : Promise < void > {
249
193
if ( ! this . _isRunning ) {
250
- throw new Error ( 'HttpStreamTransport not running' ) ;
194
+ logger . warn ( 'Attempted to send message, but HTTP transport is not running' ) ;
195
+ return ;
251
196
}
252
197
253
198
const activeSessions = Object . entries ( this . _transports ) ;
@@ -282,16 +227,6 @@ export class HttpStreamTransport extends AbstractTransport {
282
227
return ;
283
228
}
284
229
285
- if ( this . _pingInterval ) {
286
- clearInterval ( this . _pingInterval ) ;
287
- this . _pingInterval = undefined ;
288
- }
289
-
290
- for ( const timeout of this . _pingTimeouts . values ( ) ) {
291
- clearTimeout ( timeout ) ;
292
- }
293
- this . _pingTimeouts . clear ( ) ;
294
-
295
230
for ( const transport of Object . values ( this . _transports ) ) {
296
231
try {
297
232
await transport . close ( ) ;
0 commit comments