Skip to content
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

Receive Error Connection - Invalid handle #380

Open
happyoka opened this issue Feb 18, 2022 · 0 comments
Open

Receive Error Connection - Invalid handle #380

happyoka opened this issue Feb 18, 2022 · 0 comments

Comments

@happyoka
Copy link

I tried to send multiple messages at one time. Sometime, my application will face invalid handle which connection error. May i know what is my issue? How to troubleshoot?

The message broker I using is Solace Pub/Sub+

Code
===========================================================================
  const connectionOptions : ConnectionOptions = {
     host: this.hostname,
     username: this.username,
     password: this.password,
     port: this.port,
     reconnect: true,
     max_reconnect_delay: 5000,
   };
   await this.conn.open();
   this.conn.on(ConnectionEvents.connectionOpen, (context)=> {
     console.log('Connection Open');
   });
   this.conn.on(ConnectionEvents.connectionError, (context)=> {
     console.log('Connection Error');
     console.log(context);
   });
   this.conn.on(ConnectionEvents.connectionClose, (context)=> {
     console.log('Connection Close');
     console.log(context);
   });
   this.conn.on(ConnectionEvents.protocolError, (context)=> {
     console.log('Protocol Error');
     console.log(context);
   });
   this.conn.on(ConnectionEvents.error, (context)=> {
     console.log('Error');
     console.log(context);
   });

 public async subscribe(address : string): Promise<void> {
   if (!this.isConnectionExist()) {
     return console.log('Connection is not created.');
   }
   const receiverName = 'amqp-listener-menu-receiver';
   const receiverOptions : ReceiverOptions = {
     name: receiverName,
     autoaccept: true,
     source: {address: address},
     onSessionError: (context : EventContext) => {
       const sessionError = context.session && context.session.error;
       if (sessionError) {
         console.log('>>>>> [%s] An error occurred for session of receiver "%s": %O.',
             this.conn.id, receiverName, sessionError);
       }
     },
   };
   this.receiver = await this.conn.createReceiver(receiverOptions);
   this.receiver.on(ReceiverEvents.message, (context : EventContext) => {
     console.log('Receiving Message');
     //console.log(context.message!.body);
   });
   this.receiver.on(ReceiverEvents.receiverError, (context : EventContext) => {
     console.log('Receiver Error');
     console.log(context);
   });
   this.receiver.on(ReceiverEvents.receiverDrained, (context : EventContext) => {
     console.log('ReceiveDrained');
     console.log(context);
   });
   this.receiver.on(ReceiverEvents.receiverClose, (context : EventContext) => {
     console.log('Receiver Closed');
     console.log(context);
     this.receiver?.close();
   });
 }


Log File
===========================================================================
_context: Error: Invalid handle 1
     at Session._get_link (C:\code\amqp-listener\node_modules\rhea\lib\session.js:734:15)
     at Session.on_transfer (C:\code\amqp-listener\node_modules\rhea\lib\session.js:759:43)
     at Connection.<computed> [as on_transfer] (C:\code\amqp-listener\node_modules\rhea\lib\connection.js:836:30)
     at c.dispatch (C:\code\amqp-listener\node_modules\rhea\lib\types.js:946:33)
     at Transport.read (C:\code\amqp-listener\node_modules\rhea\lib\transport.js:109:36)
     at SaslClient.read (C:\code\amqp-listener\node_modules\rhea\lib\sasl.js:328:26)
     at Connection.input (C:\code\amqp-listener\node_modules\rhea\lib\connection.js:556:35)
     at Socket.emit (node:events:390:28)
     at addChunk (node:internal/streams/readable:315:12)
     at readableAddChunk (node:internal/streams/readable:289:9),
 connection: Connection {
   _events: [Object: null prototype] {
     connection_open: [Array],
     connection_error: [Array],
     connection_close: [Array],
     protocol_error: [Array],
     error: [Array]
   },
   _eventsCount: 5,
   _maxListeners: undefined,
   actionInitiated: 0,
   _connection: Connection {
     options: [Object],
     container: [Container],
     registered: false,
     state: [EndpointState],
     local_channel_map: [Object],
     remote_channel_map: [Object],
     local: [Object],
     remote: [Object],
     session_policy: [Object],
     amqp_transport: [Transport],
     sasl_transport: [SaslClient],
     transport: [SaslClient],
     conn_established_counter: 3,
     heartbeat_out: undefined,
     heartbeat_in: undefined,
     abort_idle: undefined,
     socket_ready: true,
     scheduled_reconnect: undefined,
     default_sender: undefined,
     closed_with_non_fatal_error: false,
     _events: [Object: null prototype],
     _eventsCount: 13,
     is_server: false,
     socket: [Socket],
     previous_input: null,
     saved_error: Error: Invalid handle 1
         at Session._get_link (C:\code\amqp-listener\node_modules\rhea\lib\session.js:734:15)
         at Session.on_transfer (C:\code\amqp-listener\node_modules\rhea\lib\session.js:759:43)
         at Connection.<computed> [as on_transfer] (C:\code\amqp-listener\node_modules\rhea\lib\connection.js:836:30)
         at c.dispatch (C:\code\amqp-listener\node_modules\rhea\lib\types.js:946:33)
         at Transport.read (C:\code\amqp-listener\node_modules\rhea\lib\transport.js:109:36)
         at SaslClient.read (C:\code\amqp-listener\node_modules\rhea\lib\sasl.js:328:26)
         at Connection.input (C:\code\amqp-listener\node_modules\rhea\lib\connection.js:556:35)
         at Socket.emit (node:events:390:28)
         at addChunk (node:internal/streams/readable:315:12)
         at readableAddChunk (node:internal/streams/readable:289:9)
   },
   container: Container {
     _events: [Object: null prototype] {},
     _eventsCount: 0,
     _maxListeners: undefined,
     _container: [Container],
     options: [Object],
     [Symbol(kCapture)]: false
   },
   options: {
     host: '172.178.105.100',
     username: 'jack',
     password: '4321',
     port: 5672,
     reconnect: [Function (anonymous)],
     max_reconnect_delay: 5000,
     operationTimeoutInSeconds: 60,
     id: 'connection-1',
     container_id: '3f4d50a5-ba20-f449-b9b9-3424bc7547c1',
     connection_details: [Function (anonymous)]
   },
   [Symbol(kCapture)]: false
 },
 container: Container {
   _events: [Object: null prototype] {},
   _eventsCount: 0,
   _maxListeners: undefined,
   _container: Container {
     options: [Object],
     id: '3f4d50a5-ba20-f449-b9b9-3424bc7547c1',
     sasl_server_mechanisms: {}
   },
   options: { id: '3f4d50a5-ba20-f449-b9b9-3424bc7547c1' },
   [Symbol(kCapture)]: false
 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant