Matthias247 / jawampa

Web Application Messaging Protocol (WAMP v2) support for Java
Apache License 2.0
148 stars 56 forks source link

Getting publication succeeded callback while network is disconnected #109

Closed thePunIssuer closed 7 years ago

thePunIssuer commented 7 years ago

Steps to reproduce:

  1. Connect to WAMP router.
  2. Disconnect computer from network. In my case, netctl-auto disable-all to disable wifi.
  3. Publish an event and wait for confirmation:
    client.publish("event", null, objectNode)
        .subscribe(
            publicatonId -> logger.trace("Published, id: {}", publicationId),
            error -> logger.trace("error publishing:", error));

Expected result:

Getting a log message that says publishing did not work, or no message at all.

Actual result:

Log says: Published, id: 0. It also returns id 0 while connected and online.

Versions:

jawampa 0.5.0 Crossbar 17.6.1-3

Matthias247 commented 7 years ago

The reason is most likely here: https://github.com/Matthias247/jawampa/blob/master/jawampa-core/src/main/java/ws/wamp/jawampa/client/SessionEstablishedState.java#L438-L441

As long as RequireAcknowledge option is not used no publication confirmations over the network will be used and all publishes which happen at a point of time when the last reported network state was "network available" will be reported as succesful.

The other question is why your client does not detect that the network is down, because if network is detected as down you should get the expected error: https://github.com/Matthias247/jawampa/blob/master/jawampa-core/src/main/java/ws/wamp/jawampa/WampClient.java#L253-L255

That's most likely because your disabling of WIFI will not lead the OS to shutdown all sockets which used WIFI. The disconnect might only be detected later on as soon as some send operations on the socket failed.

thePunIssuer commented 7 years ago

Enabling network acknowledgement did the trick for me. Thank you very much! <3