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

Issues with clean session (clearSession) #12

Open
jbwdevries opened this issue Oct 24, 2019 · 2 comments
Open

Issues with clean session (clearSession) #12

jbwdevries opened this issue Oct 24, 2019 · 2 comments

Comments

@jbwdevries
Copy link

When connecting to a server without a clean session, the application does not seem to connect properly.

On the server side, I see:

1571925100: New connection from 192.168.48.135 on port 443.
1571925100: New client connected from 192.168.48.135 as session-f931762b-97c6-49b6-a18a-e2daaf62dc57 (c0, k100, u'stresstest').
1571925102: Client session-f931762b-97c6-49b6-a18a-e2daaf62dc57 disconnected.
--
1571925130: New connection from 192.168.48.135 on port 443.
1571925130: Client session-f931762b-97c6-49b6-a18a-e2daaf62dc57 disconnected.
1571925130: New client connected from 192.168.48.135 as session-f931762b-97c6-49b6-a18a-e2daaf62dc57 (c0, k100, u'stresstest').

As you can see, the server first logs a disconnect event, and then a connect event. But it also earlier logged a disconnect event for that same session ID.

The client will PINGREQ and PINGRESP properly, but not receive any messages. Possibly because the subscriptions aren't restored?

I can't really understand it. I've attached a test case scenario: Stresstest.hs.gz. I've compiled it by adding this to the cabal file:

executable stresstest
  hs-source-dirs:      app
  main-is:             Stresstest.hs
  ghc-options:         -threaded -rtsopts -with-rtsopts=-N
  build-depends:       base
                     , bytestring
                     , c-mosquitto
                     , containers
                     , data-default-class
                     , options
                     , uuid
  default-language:    Haskell2010

This scenario creates a clean session, then spams a bunch of messages to this session from a different client, and then reconnects with the session.

https://github.com/dustin/mqtt-hs does not have the same problem, so the bug is probably not in the server: mqtt-hs-stresstest.gz

I'm running mosquitto 1.4.15, there is no mention in the changelog of any bug fixes related to clean session since that version. And I'm having a hard time imagining that this would be a bug in the C library. But I can't be sure.

Any suggestions on why this might be?

@tolysz
Copy link
Owner

tolysz commented Oct 24, 2019

I do not see ( https://github.com/tolysz/c-mosquitto/blob/master/app/Main.hs ):

 M.onConnect m $ \c -> do
           print c
           M.subscribe m 0 "#"

I might have some time later to test it a bit.

@jbwdevries
Copy link
Author

Right, the .hs file is missing a subscribe call, not sure how that happened. Below a fixed version:
Stresstest.hs.gz

Same bug still shows, though.

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

2 participants