Skip to content

Commit faf8863

Browse files
authored
[BACKPORT 4.2.x] Close connection on socket end as well as error (#1098) (#1108)
* Close connection on socket `end` as well as `error` (#1098) * Fix links
1 parent 9ad6b9e commit faf8863

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

DOCUMENTATION.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ That is because our map lives in the cluster and no matter which client we use,
494494

495495
See the Hazelcast Node.js [code samples](https://github.com/hazelcast/hazelcast-nodejs-client/tree/master/code_samples) for more examples.
496496

497-
You can also see the Hazelcast Node.js [API Documentation](http://hazelcast.github.io/hazelcast-nodejs-client/api/current/docs/).
497+
You can also see the Hazelcast Node.js [API Documentation](http://hazelcast.github.io/hazelcast-nodejs-client/).
498498

499499

500500
# 2. Features
@@ -589,7 +589,7 @@ Hazelcast serializes all your objects before sending them to the server. Certain
589589

590590
> **NOTE: The `Long` type means the type provided by [long.js library](https://github.com/dcodeIO/long.js).**
591591
592-
> **NOTE: A `number` is serialized as `Double` by default. You can configure this behavior using the `defaultNumberType` serialization config option. See [API Documentation](http://hazelcast.github.io/hazelcast-nodejs-client/api/current/docs/) for more information.**
592+
> **NOTE: A `number` is serialized as `Double` by default. You can configure this behavior using the `defaultNumberType` serialization config option. See [API Documentation](http://hazelcast.github.io/hazelcast-nodejs-client/) for more information.**
593593
594594
Arrays of the `boolean`, `number`, `string`, and `Long` types can be serialized as `boolean[]`, `byte[]`, `short[]`, `int[]`, `float[]`, `double[]`, `string[]`, and `long[]` for the Java server side, respectively.
595595

@@ -615,7 +615,7 @@ However, `JSON Serialization` may be not the best way of serialization in terms
615615

616616
Or, if you want to use your own serialization method, you can use [Custom Serialization](#43-custom-serialization).
617617

618-
> **NOTE: Hazelcast Node.js client is a TypeScript-based project but JavaScript does not have interfaces. Therefore, some interfaces are given to the user by using the TypeScript files that have `.ts` extension. In this guide, implementing an interface means creating an object to have the necessary functions that are listed in the interface inside the `.ts` file. Also, this object is mentioned as `an instance of the interface`. You can search the [API Documentation](http://hazelcast.github.io/hazelcast-nodejs-client/api/current/docs/) or GitHub repository for a required interface.**
618+
> **NOTE: Hazelcast Node.js client is a TypeScript-based project but JavaScript does not have interfaces. Therefore, some interfaces are given to the user by using the TypeScript files that have `.ts` extension. In this guide, implementing an interface means creating an object to have the necessary functions that are listed in the interface inside the `.ts` file. Also, this object is mentioned as `an instance of the interface`. You can search the [API Documentation](http://hazelcast.github.io/hazelcast-nodejs-client/) or GitHub repository for a required interface.**
619619
620620
## 4.1. IdentifiedDataSerializable Serialization
621621

@@ -643,7 +643,7 @@ class Employee {
643643
}
644644
```
645645

646-
> **NOTE: Refer to `DataInput`/`DataOutput` interfaces in the [API Documentation](http://hazelcast.github.io/hazelcast-nodejs-client/api/current/docs/) to understand methods available on the `input`/`output` objects.**
646+
> **NOTE: Refer to `DataInput`/`DataOutput` interfaces in the [API Documentation](http://hazelcast.github.io/hazelcast-nodejs-client/) to understand methods available on the `input`/`output` objects.**
647647
648648
The `IdentifiedDataSerializable` interface uses `classId` and `factoryId` properties to reconstitute the object. To complete the implementation, `IdentifiedDataSerializableFactory` factory function should also be implemented and put into the `serialization.dataSerializableFactories` config option. The factory's responsibility is to return an instance of the right `IdentifiedDataSerializable` object, given the `classId`.
649649

@@ -713,7 +713,7 @@ class Customer {
713713
}
714714
```
715715

716-
> **NOTE: Refer to `PortableReader`/`PortableWriter` interfaces in the [API Documentation](http://hazelcast.github.io/hazelcast-nodejs-client/api/current/docs/) to understand methods available on the `reader`/`writer` objects.**
716+
> **NOTE: Refer to `PortableReader`/`PortableWriter` interfaces in the [API Documentation](http://hazelcast.github.io/hazelcast-nodejs-client/) to understand methods available on the `reader`/`writer` objects.**
717717
718718
Similar to `IdentifiedDataSerializable`, a `Portable` object must provide `classId` and `factoryId`. The factory function will be used to create the `Portable` object given the `classId`.
719719

@@ -1879,7 +1879,7 @@ Lifecycle Event >>> SHUTDOWN
18791879

18801880
You can add event listeners to the distributed data structures.
18811881

1882-
> **NOTE: Hazelcast Node.js client is a TypeScript-based project but JavaScript does not have interfaces. Therefore, some interfaces are given to the user by using the TypeScript files that have `.ts` extension. In this guide, implementing an interface means creating an object to have the necessary functions that are listed in the interface inside the `.ts` file. Also, this object is mentioned as "an instance of the interface". You can search the [API Documentation](http://hazelcast.github.io/hazelcast-nodejs-client/api/current/docs/) or GitHub repository for the required interface.**
1882+
> **NOTE: Hazelcast Node.js client is a TypeScript-based project but JavaScript does not have interfaces. Therefore, some interfaces are given to the user by using the TypeScript files that have `.ts` extension. In this guide, implementing an interface means creating an object to have the necessary functions that are listed in the interface inside the `.ts` file. Also, this object is mentioned as "an instance of the interface". You can search the [API Documentation](http://hazelcast.github.io/hazelcast-nodejs-client/) or GitHub repository for the required interface.**
18831883
18841884
#### 8.5.2.1. Map Listener
18851885

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ You can use the following channels for your questions and development/usage issu
125125

126126
* [GitHub repository](https://github.com/hazelcast/hazelcast-nodejs-client)
127127
* [Complete documentation](DOCUMENTATION.md)
128-
* [API documentation](http://hazelcast.github.io/hazelcast-nodejs-client/api/current/docs/)
128+
* [API documentation](http://hazelcast.github.io/hazelcast-nodejs-client/)
129129
* [Slack](https://slack.hazelcast.com)
130130
* [Google Groups](https://groups.google.com/forum/#!forum/hazelcast)
131131
* [Stack Overflow](https://stackoverflow.com/questions/tagged/hazelcast)

src/network/ConnectionManager.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,12 @@ export class ConnectionManager extends EventEmitter {
458458
);
459459
// close the connection proactively on errors
460460
socket.once('error', (err: NodeJS.ErrnoException) => {
461-
connection.close('Socket error. Connection might be closed by other side', err);
461+
connection.close('Socket error.', err);
462+
});
463+
// close the connection if socket is not readable anymore
464+
socket.once('end', () => {
465+
const reason = 'Connection closed by the other side.';
466+
connection.close(reason, new IOError(reason));
462467
});
463468
return this.initiateCommunication(socket);
464469
})

0 commit comments

Comments
 (0)