Commit Graph

108 Commits

Author SHA1 Message Date
Harshvardhan Gupta
4f45e3c127 fix: make acks thread safe (#779) 2025-02-06 09:16:05 +01:00
Damien Arrachequesne
54645ece2c fix: discard acknowledgements upon disconnection
Previously, getting disconnected while waiting for an acknowledgement
would create a memory leak, as the acknowledgement was never received
and the handler would stay in memory forever.

See also: 34cbfbb532

Related: https://github.com/socketio/socket.io-client-java/issues/446
2024-07-10 11:43:48 +02:00
Harshvardhan Gupta
b00ae8eec1 fix: make sendBuffer thread safe (#769)
Clearing the buffer upon timeout could lead to:

```
java.util.ConcurrentModificationException
	at java.base/java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:970)
	at java.base/java.util.LinkedList$ListItr.next(LinkedList.java:892)
	at io.socket.client.Socket$6$1.run(Socket.java:232)
	at java.base/java.util.TimerThread.mainLoop(Timer.java:556)
	at java.base/java.util.TimerThread.run(Timer.java:506)
```

Related:

- https://github.com/socketio/socket.io-client-java/issues/710
- https://github.com/socketio/socket.io-client-java/issues/727
- https://github.com/socketio/socket.io-client-java/pull/758
- https://github.com/socketio/socket.io-client-java/issues/759
2024-07-10 11:10:17 +02:00
Damien Arrachequesne
95ecf222d2 fix: prevent socket from reconnecting after middleware failure
See also: d54d12ce63
2022-07-10 22:59:57 +02:00
Damien Arrachequesne
c7d50b8ae9 feat: implement catch-all listeners
Syntax:

```java
socket.onAnyIncoming(new Emitter.Listener() {
    @Override
    public void call(Object... args) {
        // ...
    }
});

socket.onAnyOutgoing(new Emitter.Listener() {
    @Override
    public void call(Object... args) {
        // ...
    }
});
```

Related:

- https://github.com/socketio/engine.io-client-java/issues/99
- https://github.com/socketio/socket.io-client-java/issues/243
- https://github.com/socketio/socket.io-client-java/issues/475
2022-07-08 20:39:36 +02:00
Damien Arrachequesne
fca3b9507d feat: emit with timeout
This feature allows to send a packet and expect an acknowledgement from
the server within the given delay.

Syntax:

```java
socket.emit("hello", "world", new AckWithTimeout(5000) {
    @Override
    public void onTimeout() {
        // ...
    }

    @Override
    public void onSuccess(Object... args) {
        // ...
    }
});
```

Related:

- https://github.com/socketio/socket.io-client-java/issues/309
- https://github.com/socketio/socket.io-client-java/pull/517
2022-07-08 19:46:18 +02:00
Damien Arrachequesne
0cbf01eb25 fix: ensure randomizationFactor is always between 0 and 1
Using a randomizationFactor value above 1 could lead to generating a
negative duration, then throwing:

> java.lang.IllegalArgumentException: delay < 0: -1012
> at java.util.Timer.schedule(Timer.java:454)
> at io.socket.client.Manager.reconnect(Manager.java:544)

This error does not seem related to a long overflow (in the
BigInteger.longValue() operation), because the BigInteger.min(this.max)
operation before should prevent it.

Related: https://github.com/socketio/socket.io-client-java/issues/349
2022-07-02 09:02:48 +02:00
Damien Arrachequesne
d324e7f396 fix: emit a CONNECT_ERROR event upon connection failure
See also: 53c73749a8
2021-04-27 00:17:05 +02:00
Damien Arrachequesne
e8ffe9d138 fix: ensure the payload format is valid
This commit should prevent some NPE issues encountered after the
parsing of the packet.

Related:

- https://github.com/socketio/socket.io-client-java/issues/642
- https://github.com/socketio/socket.io-client-java/issues/609
- https://github.com/socketio/socket.io-client-java/issues/505
2021-04-27 00:14:24 +02:00
Damien Arrachequesne
4885e7d59f fix: ensure buffered events are sent in order
Before this commit, an event sent in the "connect" handler could be
sent before the events that were buffered while disconnected.

Related: https://github.com/socketio/socket.io-client/issues/1458
2021-04-27 00:12:46 +02:00
Damien Arrachequesne
48fec45740 refactor: minor cleanup
- replace explicit types by <>
- remove unnecessary interface modifiers
2021-04-26 11:19:02 +02:00
Damien Arrachequesne
67fd5f34a3 fix: fix usage with ws:// scheme
The URL constructor does not support the ws:// scheme, and would throw:

> java.net.MalformedURLException: unknown protocol: ws

Related:

- https://github.com/socketio/socket.io-client-java/issues/650
- https://github.com/socketio/socket.io-client-java/issues/555
- https://github.com/socketio/socket.io-client-java/issues/233
2021-04-26 11:17:41 +02:00
Damien Arrachequesne
5b5b91cb01 test: fix random test failures 2021-04-26 09:12:55 +02:00
Lloyd Junbong Lee
49068d3cc5 feat: add options builder (#304) 2020-12-15 00:16:59 +01:00
Damien Arrachequesne
79cb27fc97 feat: add support for Socket.IO v3
Including:

- 969debe88c
- 6494f61be0
- 132f8ec918
- f8f60fc860

Reference: https://github.com/socketio/socket.io-protocol#difference-between-v5-and-v4
2020-12-15 00:05:22 +01:00
Alireza Ghaffari
567372ecfa fix: handle case where URI.getHost() returns null (#484)
It seems that URI.getHost() might return null on some Samsung devices.

Related: https://stackoverflow.com/questions/39645789/android-websocket-connection-failed-galaxy-s4
2020-12-10 12:20:06 +01:00
Kushtrim Pacaj
54b73114d1 fix: don't process socket.connect() if we are already re-connecting (#577) 2020-12-10 11:47:20 +01:00
nkzawa
eeadb50aa9 clean up imports 2017-07-14 14:22:44 +09:00
nkzawa
6e5fab39de Merge branch 'master' into fix/compatible-v2 2017-07-14 14:20:39 +09:00
nkzawa
ad4449bfee explicitly clear onDecoded callback 2017-07-14 14:11:27 +09:00
nkzawa
2ec4167eb8 add tests 2017-07-14 12:40:22 +09:00
nkzawa
3d98ed9fe9 simplify custom encoder/decoder 2017-07-14 11:50:25 +09:00
Naoyuki Kanezawa
9b5c684349 Merge pull request #423 from sergey-davydov/donotformateventdata
Add condition to log only if fine level is loggable
2017-07-14 11:25:20 +09:00
nkzawa
7279919ef9 enable to implement custom parser 2017-07-14 11:24:43 +09:00
nkzawa
06068654c3 improve Socket#emit 2017-07-14 00:09:44 +09:00
nkzawa
29b0f36542 update Parser 2017-07-13 22:59:50 +09:00
nkzawa
f6bb7678b6 fix generating Id 2017-07-13 21:54:33 +09:00
nkzawa
4811368854 send query on connecti 2017-07-12 01:09:11 +09:00
nkzawa
9d6947a015 bump engine.io-client 2017-07-11 21:54:48 +09:00
Sergey Davydov
229a820bf5 Add condition to log only if fine level is loggable
Even if FINE level is not loggable String.format() works every time and
tries to format string with all the events. Sometimes it causes
OutOfMemory exceptions.
2017-05-28 13:01:18 +03:00
nkzawa
48420a6c6f improve manager disconnection and cleanup 2016-02-01 01:03:49 +09:00
nkzawa
0d4d455704 add ping and pong events 2016-02-01 00:48:57 +09:00
nkzawa
599eb98c6e fix disconnection while in opening state 2016-01-31 23:55:53 +09:00
nkzawa
f7810c19d3 create a new connection when path is the same 2016-01-31 17:33:28 +09:00
nkzawa
4aed6c68af don't create json array twice 2016-01-30 00:02:06 +09:00
Ciro S. Costa
f0832ffc61 Fixes event type when emitting binary_ack
When submitting binary data in an Ack to the server the packet's type
was not the expected (should be 6 - binary_ack - and not 3 - ack).

This commit introduces tests as well a fix for the given problem.
2016-01-27 12:11:22 -03:00
Naoyuki Kanezawa
a3f2b8cd00 Merge pull request #259 from DevFactory/release/collection-isempty-fix-1
Code Quality Improvement - Collection.isEmpty() should be used to test for emptiness
2015-12-18 11:51:44 +09:00
Naoyuki Kanezawa
1ef3b2cae7 Merge pull request #258 from DevFactory/release/redundant-field-initializer-fix-1
Code Quality Improvement - Redundant Field Initializer
2015-12-18 11:49:36 +09:00
Naoyuki Kanezawa
669696fee4 Merge pull request #257 from DevFactory/release/constructors-should-only-call-non-overridable-methods-fix-1
Code Quality Improvement - Constructors should only call non-overridable methods
2015-12-18 11:48:36 +09:00
Naoyuki Kanezawa
57d8e5ebff Merge pull request #256 from DevFactory/release/objects-should-be-compared-with-equals()-fix-1
Code Quality Improvement - Objects should be compared with "equals()"
2015-12-18 11:44:44 +09:00
Naoyuki Kanezawa
9b33f23875 Merge pull request #255 from DevFactory/release/exception-handlers-fix-1
Code Quality Improvement - Exception handlers should preserve the original exception
2015-12-18 11:42:36 +09:00
nkzawa
8c29b2ef9c fix backoff calucuration #245 2015-12-14 11:43:44 +09:00
nkzawa
9cdf6c0bbd change lint settings and fix warnings 2015-12-13 04:00:08 +09:00
nkzawa
bc45e15d03 suppress cast warnings 2015-12-13 02:52:55 +09:00
Christian Ivan
fff5cb3e25 Code Quality Improvement - Constructors should only call non-overridable methods
update
2015-12-06 15:56:21 +07:00
Christian Ivan
2143774a1e Code Quality Improvement - Exception handlers should preserve the original exception
Update

Update
2015-12-06 15:38:31 +07:00
Christian Ivan
eac538dfe0 Code Quality Improvement - Objects should be compared with "equals()"
Update
2015-12-02 23:11:17 +07:00
Christian Ivan
2b7a40b96a Code Quality Improvement - Redundant Field Initializer 2015-12-02 17:25:37 +07:00
Christian Ivan
d364404501 Code Quality Improvement - Collection.isEmpty() should be used to test for emptiness 2015-12-02 17:17:46 +07:00
nkzawa
34277c5d47 fix the case reconnection doesn't work 2015-10-11 12:03:58 +09:00