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

Publishing a message fails when there is no connection to a broker #133

Open
antp opened this issue Mar 3, 2021 · 1 comment
Open

Publishing a message fails when there is no connection to a broker #133

antp opened this issue Mar 3, 2021 · 1 comment

Comments

@antp
Copy link

antp commented Mar 3, 2021

Tortoise: 0.9.8
Elixir 1.11.3-otp-22
Erlang 23.2.6

Scenario:
The boker is unavailable at startup.
The connection is retrying in the background.

Calls to:
Tortoise.publish("my_client_id", "foo/bar", "Hello from the World of Tomorrow !", qos: 1)
-- or --
Tortoise.publish_sync("my_client_id", "foo/bar", "Hello from the World of Tomorrow !", qos: 1)
block forever.

This is due to the default timeout of :infinity at line 329 in Tortoise.connection.
I realise that I can put logic in place as the application has not been notified of a connection state change to not allow publishing. This was my first naive attempt at using Tortoise.

Passing a timeout value causes via either of the calls causes the following match errors:
** (WithClauseError) no with clause matching: {:error, :timeout}
(tortoise 0.9.8) lib/tortoise.ex:269: Tortoise.publish/4

** (WithClauseError) no with clause matching: {:error, :timeout}
(tortoise 0.9.8) lib/tortoise.ex:329: Tortoise.publish_sync/4

Should the {:error, :timeout} be handled in Tortoise.publish or should the timeout be translated to {:error, :unknown_connection}?

The documentation is also incorrect in this respect.

Happy to help with pull request or is it a case of wait for mqtt-5 branch?

@antp
Copy link
Author

antp commented Mar 3, 2021

Just noticed this already has a pull request #128

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