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

initial websocket support + other cleanup & fixes. #415

Merged
merged 6 commits into from May 24, 2018

Conversation

Projects
None yet
4 participants
@lt-holman
Copy link
Contributor

lt-holman commented Feb 12, 2018

This patch set is the initial work for WebSocket support in the C paho library. This patch does not make use of any external WebSocket library and encodes and decodes the WebSocket frames internally as the python version of paho, seems to take this approach. (See WebSocket.h & WebSocket.c). It attempts to use OpenSSL and/or Operating System methods for Base64 encoding & SHA1 hashes. However, if nothing else is available it does contain algorithms for generating these values. These are only used in the initial WebSocket handshake.

This patch was tested on Linux in the following environments

  • mqtt + MQTTClient = works

  • mqtt+ ssl + MQTTClient = works

  • mqtt + websocket + MQTTClient = works

  • mqtt + ssl + websocket + MQTTClient = works

  • mqtt + MQTTAsync = works

  • mqtt + ssl + MQTTAsync = works

  • mqtt + websocket + MQTTAsync = works

  • mqtt + ssl + websocket + MQTTAsync = works

  • It was compiled under Windows, but not run (other than the simple unit tests).

  • It was not built on any other operating system. So macros for encoding & decoding to big-endian may need to be added for them.

To enable websockets.... set the server URI to ws://localhost:80/subdir for regular websockets or wss://localhost:443/subdir for secure websockets (note that: wss only available when compiled with OpenSSL). In both, the /subdir portion is optional, if not specified it will default to an HTTP request of /mqtt

@icraggs

This comment has been minimized.

Copy link
Contributor

icraggs commented Feb 13, 2018

Hi Keith. This is great, thanks! I've not tried it yet, but my first observation is that for new files the copyright should be the copyright owner, which could be the company you work for, or you yourself.

Secondly, because this is >1000 lines, we need to have a bit more of an IP check. I'll get to that tomorrow.

@icraggs

This comment has been minimized.

Copy link
Contributor

icraggs commented Feb 15, 2018

Keith, for the Eclipse IP process, I need you to (re)confirm three things please:

  1. Contains No Cryptography - OpenSSL or the OS is used for some capabilities, but we already use OpenSSL in the client so I think this is fine.
  2. Is Developed from Scratch (without incorporating content from elsewhere) – the CLA asks for this, but please confirm.
  3. Is 100% Project License Code Again I assume this is obvious that you are happy for the EPL and EDL to apply, as per the rest of the project.

I really appreciate the contribution, and the fact that no other libraries have been used. This means this code could be used in other projects too, like the Paho embedded client.

@lt-holman

This comment has been minimized.

Copy link
Contributor Author

lt-holman commented Feb 15, 2018

Hi Ian,

  1. Cryptography: I use OPENSSL if it's available, but when compiled without (for mqttc.so and mqtta.so libs), I then use the OS in windows... However, I do add a SHA1 hash algorithm for other operating systems in this case... it's included in SHA1.[ch]. This is used to provide websocket support without compiling with openssl.. "ws:// " addresses... (It's needed in the negotiation of the websocket-key in the HTTP GET request and to verify in the HTTP websocket upgrade response. I also include a Base64 encoding and decoding algorithm, but this usually isn't considered cryptography. This is also used just in the header negotiation of the websocket-key
  2. I developed it from scratch, it took me about a week. I used an online reference for my SHA1 algorithm from here: https://www.oryx-embedded.com/doc/sha1_8c_source.html... it's not copied but was used as a reference. All other code came from reading and interpreting the web socket RFC.
  3. Project code I checked with my company for releasing Open Source code to the community and they suggested I change to an Apache license (as it's more permissible then the EPL, but if required I can make it EPL)... I can update the commit with a new copyright on the new files, if you would like

Another, note, your contribution.md file indicates to update the tests for new features, but because I could quite understand your test suite setup which seems to come from another repository. But I think that should be as easy as pointing to another MQTT broker setup behind a websocket and then running all the tests again. The only limitation is the websocket frame size. (As I limit to outgoing messages to 1 frame, this seemed to be the same case in python paho).

@icraggs

This comment has been minimized.

Copy link
Contributor

icraggs commented Feb 16, 2018

Thanks Keith. That's great. As you apparently work for WindRiver the copyright statements in the new files should refer to that entity rather than IBM.

  1. Ok

  2. I think that referring to GPL licensed code is ok, we'll find out.

  3. Paho is licensed under both the EPL and EDL - the consumer can choose which. I believe the combination is as liberal as the Apache license. The EDL allows the inclusion in Linux distributions for instance. The headers you have included already say EPL and EDL anyway, not Apache.

I think it should be straightforward to add tests, as you say. I think both brokers used for testing have web sockets support.

@icraggs

This comment has been minimized.

Copy link
Contributor

icraggs commented Feb 16, 2018

Please update the copyright statements on the new files to refer to your employer. Thanks.

@icraggs

This comment has been minimized.

Copy link
Contributor

icraggs commented Feb 16, 2018

@lt-holman lt-holman force-pushed the lt-holman:develop branch from c2ae3ce to 487180d Feb 18, 2018

@lt-holman

This comment has been minimized.

Copy link
Contributor Author

lt-holman commented Feb 18, 2018

Ian, I fixed the copyright on the 6 new files: SHA1.[ch], Base64.[ch] & WebSocket.[ch]

@icraggs

This comment has been minimized.

Copy link
Contributor

icraggs commented Feb 20, 2018

Thanks Keith. The IP review is now underway.

@icraggs

This comment has been minimized.

Copy link
Contributor

icraggs commented Mar 13, 2018

Keith, I've been asked by Eclipse legal to ask you if your implementation is consistent with the SHA1 pseudocode published via Wikipedia [1].

[1] https://en.wikipedia.org/wiki/SHA-1#SHA-1_pseudocode

I presume this is to be assured that the core of the implementation is public domain.

Thanks.

@icraggs icraggs self-assigned this Mar 13, 2018

@icraggs icraggs added the enhancement label Mar 13, 2018

@icraggs icraggs added this to the 1.3 milestone Mar 13, 2018

@lt-holman

This comment has been minimized.

Copy link
Contributor Author

lt-holman commented Mar 14, 2018

Ian, yes it is.. there a few minor changes for slight efficiency, and that the block size is known before the algorithm in the Wikipedia article (for padding purposes), where the algorithm submitted just adds any required padding into the last block at the end.... Anyhow, the end result is the same as the algorithm presented in the public domain..

A little more detail on reading the pseudo code versus the code presented:

  1. You can see that the magic values for h0-4 (I use an array) are all initialised to the same values:
    h0 = 0x67452301
    h1 = 0xEFCDAB89
    h2 = 0x98BADCFE
    h3 = 0x10325476
    h4 = 0xC3D2E1F0

  2. The SHA1_ProcessBlock is equivalent to the "process chunk" in the Wikipedia article.

  3. The values in the Wikipedia article called: a, b, c, d, e... I just make them an array of blks[4] respectfully... The w variable is initialised inside the 1 loop instead SHA1_ProcessBlock instead of outside as per the pseudo code version.

  4. In the Pseudo uses the variable f, k and temp... I do all this in one line each with the tmp variable.

  5. The only real difference is in the Wikipedia article the length of the data to be encoded is known at the beginning and padded before processing... Where is in my code, any required padding is added in SHA1_Final function then sent for 1 final block to be processed before producing the final hash.

The end result is the same as the one in the public domain.

@icraggs

This comment has been minimized.

Copy link
Contributor

icraggs commented Mar 14, 2018

Thanks Keith.

@icraggs

This comment has been minimized.

Copy link
Contributor

icraggs commented Mar 15, 2018

Hi Keith. A comment from Eclipse legal is:

_I stumbled across the following comment:

" partially taken from: https://www.oryx-embedded.com/doc/sha1_8c_source.html".

Given the contributor indicated nothing was copied, I think this comment is misleading and could be confusing to others as well.

Could you please ask for it to be rephrased.

Thanks._

I think "taken" could be interpreted as "copied". You could omit the comment altogether, or phrase it in such a way that it definitely means no code was copied.

@lt-holman lt-holman force-pushed the lt-holman:develop branch from 487180d to b4c1249 Mar 16, 2018

@lt-holman

This comment has been minimized.

Copy link
Contributor Author

lt-holman commented Mar 16, 2018

@lt-holman lt-holman force-pushed the lt-holman:develop branch from b4c1249 to 103f6d0 Mar 17, 2018

@icraggs

This comment has been minimized.

Copy link
Contributor

icraggs commented Mar 19, 2018

Thanks again.

@icraggs

This comment has been minimized.

Copy link
Contributor

icraggs commented Apr 11, 2018

We have approval! It came through in March, but I hadn't noticed. I'll look to merge it soon - it seems I have some conflicts to resolve :-)

@icraggs

This comment has been minimized.

Copy link
Contributor

icraggs commented Apr 13, 2018

I just started trying this out. How did you test it Keith? I had to add checks for connection strings starting with ws:// or wss:// to avoid getting BAD_PROTOCOL. I tried it against the Paho test broker, but the session hung. I haven't gone much further that that right now, but am wondering if there is an easy way to show it working first?

@lt-holman

This comment has been minimized.

Copy link
Contributor Author

lt-holman commented Apr 16, 2018

I tested it against a Mosquitto broker listening on websockets on my Linux box. It all went through. You are correct to add "ws://" or "wss://" as per my comments. I didn't know how to run the test broker, wasn't clear to me.

@icraggs

This comment has been minimized.

Copy link
Contributor

icraggs commented Apr 17, 2018

Ok, now the tests I've tried work the same against Mosquitto and the Paho test broker.

(FYI, to run the Paho test broker:

git clone git@github.com:eclipse/paho.mqtt.testing.git
cd paho.mqtt.testing/interoperability
python3 startbroker.py -c config.file)

test 1 of test4.c works - that's MQTTAsync. There's a segfault in a subsequent test which will need looking into. So we have a basic async test working. 👍

The connect for MQTTClient hangs. The trace gets to "WebSocket connection upgraded" but then seems to stall. Do you have any thoughts on that?

@fpagliughi fpagliughi referenced this pull request Apr 29, 2018

Closed

WebSocket support #111

lt-holman added some commits Feb 6, 2018

WebSocket: initial websocket support + utilities
closes: #166

This patch provides an initial implementation for websocket support for
paho. For the websocket specification see RFC 6455.  The purpose of this
patch is to allow connnecting to an MQTT broker listening on a websocket
port (typically 80 [HTTP] or 443 [HTTPS]) to be able to communicate with
a client using the paho library.  Using websockets to communicate increases
the packet overhead both sending and receiving as well as additional setup
and ping packets.  However, using websockets allows for communications on
standard HTTP/HTTPS ports which are generally already configured by
firewalls to allow outside communications.

To use websockets, prefix the connection URI with either: "ws://" or
"wss://" for either websockets or secure websockets, repectfully.

Signed-off-by: Keith Holman <keith.holman@windriver.com>
clients: add defines for connect states
To help understand the various connecting states this patch introduces
defines with the various states.  This helps make the code a bit easier
to understand.

Signed-off-by: Keith Holman <keith.holman@windriver.com>
Base64: compile a simple base64 test program
This patch adds a simple base64 test program to the compilation for
testing the algorithm.  The base64 algorithm is used for the initial
WebSocket handshake.

Signed-off-by: Keith Holman <keith.holman@windriver.com>
SHA1: compile a simple sha1 test program
This patch adds a simple sha1 test program to the compilation for
testing the algorithm.  The sha1 algorithm is used for the initial
WebSocket handshake.

Signed-off-by: Keith Holman <keith.holman@windriver.com>
build: various warning fixes
This patch fixes various warnings produced during the build the most
common warning, is the truncation of "size_t" (usually unsigned long) to
(int).  This patch explicitly casts the result to "int" in these cases
to supress the warning.  Additionally, this patch includes a fix to an
internal library load function to take a "const char *" parameter
instead of a "char *" parameter.

Signed-off-by: Keith Holman <keith.holman@windriver.com>
websocket: fixes to work with paho test suite
This patch contains some fixes to work with the paho test suite.

Signed-off-by: Keith Holman <keith.holman@windriver.com>

@lt-holman lt-holman force-pushed the lt-holman:develop branch from 52dcbd5 to 73cc3ea May 2, 2018

@djarvis

This comment has been minimized.

Copy link

djarvis commented May 10, 2018

Using paho_cs_sub sample program to try to connect to ws://myserver/mqtt but it comes back with Failed to connect (-1). Should this sample program be working?

@lt-holman

This comment has been minimized.

Copy link
Contributor Author

lt-holman commented May 10, 2018

@djarvis The sample program takes a "host", you entered an "address"... So that's why the error. But I do understand the confusion.

More specifically, the problem is internal inside the sample program, the host and port are being concatenated then passed to MQTTClient_connect as the uri... So the program is trying to connect as: "ws://myserver/mqtt:1884"... which is not a vaild address.. hence the "failed to connect" error. I've tested the program and connecting with the host "ws://localhost" (no /mqtt).. connects just fine on my tests, as /mqtt is the default GET parameter used, if one isn't specified in the uri.

So the sample app be fixed to handle a sub-directory as part of the host? I'm not sure, The second question is, if so, I don't know if it should be part of the PR... Another option would be to take a URI as a parameter, and not a "host" and "port".

@djarvis

This comment has been minimized.

Copy link

djarvis commented May 11, 2018

I got past the url name/port thing. I am trying to connect to an ASP.NET Core MQTTNet-based broker. When I run the paho_c_sub sample program I can see that I hit the server and it even hits a callback to validate the connection on the server, so some or most of the websocket-layer stuff seems to be working. Nonetheless in the end get a -1 connection error due to something during CONNACK arrival.

Here is a trace with trace level at maximum, I commented where the log differs compared against hitting ws://test.mosquitto.org:8080, which works fine.

url is ws://desktop-ohoplih:5050
clientid is xxx
=========================================================
                   Trace Output
Product name: Paho Synchronous MQTT C Client Library
Version: 1.2.1
Build level: Fri May 11 14:21:50 EDT 2018
/proc/version: Linux version 4.15.0-20-generic (buildd@lgw01-amd64-039) (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)) #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018

=========================================================
19691231 190000.000 (1230759744)  (1)> Socket_outInitialize:133
19691231 190000.000 (1230759744)   (2)> SocketBuffer_initialize:94
19691231 190000.000 (1230759744)   (2)< SocketBuffer_initialize:98
19691231 190000.000 (1230759744)  (1)< Socket_outInitialize:146
19691231 190000.000 (1230759744)  (1)> MQTTStrncpy:763
19691231 190000.000 (1230759744)  (1)< MQTTStrncpy:773
19691231 190000.000 (1230759744)  (1)> MQTTStrncpy:763
19691231 190000.000 (1230759744)  (1)< MQTTStrncpy:773
19691231 190000.000 (1230759744)  (1)> Thread_create_sem:191
19691231 190000.000 (1230759744)  (1)< Thread_create_sem:206 (0)
19691231 190000.000 (1230759744)  (1)> Thread_create_sem:191
19691231 190000.000 (1230759744)  (1)< Thread_create_sem:206 (0)
19691231 190000.000 (1230759744)  (1)> Thread_create_sem:191
19691231 190000.000 (1230759744)  (1)< Thread_create_sem:206 (0)
19691231 190000.000 (1230759744)  (1)> Thread_create_sem:191
19691231 190000.000 (1230759744)  (1)< Thread_create_sem:206 (0)
19691231 190000.000 (1230759744)  (1)> MQTTPersistence_create:51
19691231 190000.000 (1230759744)  (1)< MQTTPersistence_create:97 (0)
19691231 190000.000 (1230759744)  (1)> MQTTPersistence_initialize:112
20180511 163111.549 (1230759744)  (1)< MQTTPersistence_initialize:120 (0)
20180511 163111.549 (1230759744)  (1)> MQTTPersistence_restoreMessageQueue:616
20180511 163111.549 0 queued messages restored for client xxx
20180511 163111.549 (1230759744)  (1)< MQTTPersistence_restoreMessageQueue:651 (0)
20180511 163111.549 (1230759744) (0)< MQTTClient_create:417 (0)
Set version to 3.1
20180511 163111.549 (1230759744) (0)> MQTTClient_connect:1272
20180511 163111.549 (1230759744)  (1)> MQTTClient_connectURI:1135
20180511 163111.549 (1230759744)   (2)> MQTTClient_connectURIVersion:885
20180511 163111.549 Connecting to serverURI desktop-ohoplih:5050 with MQTT version 3
20180511 163111.549 (1230759744)    (3)> MQTTProtocol_connect:111
20180511 163111.549 (1230759744)     (4)> MQTTProtocol_addressPort:57
20180511 163111.549 (1230759744)     (4)< MQTTProtocol_addressPort:89
20180511 163111.549 (1230759744)     (4)> Socket_new:670
20180511 163111.549 New socket 3 for desktop-ohoplih:5050, port 5050
20180511 163111.549 (1230759744)      (5)> Socket_addSocket:175
20180511 163111.549 (1230759744)       (6)> Socket_setnonblocking:85
20180511 163111.549 (1230759744)       (6)< Socket_setnonblocking:90 (0)
20180511 163111.549 (1230759744)      (5)< Socket_addSocket:198 (0)
20180511 163111.549 (1230759744)      (5)> Socket_error:107
20180511 163111.549 (1230759744)      (5)< Socket_error:116 (115)
20180511 163111.550 Connect pending
20180511 163111.550 (1230759744)     (4)< Socket_new:786 (115)
20180511 163111.550 (1230759744)    (3)< MQTTProtocol_connect:150 (115)
20180511 163111.550 (1230759744)    (3)> MQTTClient_waitfor:1897
20180511 163111.550 (1230759744)     (4)> MQTTClient_cycle:1815
20180511 163111.550 (1230759744)      (5)> Socket_getReadySocket:239
20180511 163111.550 (1230759744)       (6)> Socket_continueWrites:929
20180511 163111.550 (1230759744)       (6)< Socket_continueWrites:953 (0)
20180511 163111.550 (1230759744)       (6)> isReady:215
20180511 163111.550 (1230759744)       (6)< isReady:220 (1)
20180511 163111.550 (1230759744)      (5)< Socket_getReadySocket:311 (3)
20180511 163111.550 (1230759744)      (5)> MQTTClient_retry:1795
20180511 163111.550 (1230759744)       (6)> MQTTProtocol_keepalive:527
20180511 163111.550 (1230759744)       (6)< MQTTProtocol_keepalive:560
20180511 163111.550 (1230759744)       (6)> MQTTProtocol_retry:644
20180511 163111.550 (1230759744)       (6)< MQTTProtocol_retry:663
20180511 163111.550 (1230759744)      (5)< MQTTClient_retry:1805
20180511 163111.550 (1230759744)     (4)< MQTTClient_cycle:1886 (0)
20180511 163111.550 (1230759744)    (3)< MQTTClient_waitfor:1986 (0)
20180511 163111.550 Calling WebSocket_connect(), m->serverURI is desktop-ohoplih:5050
20180511 163111.651 (1230759744)    (3)> MQTTProtocol_addressPort:57
20180511 163111.651 (1230759744)    (3)< MQTTProtocol_addressPort:89
20180511 163111.651 (1230759744)    (3)> Socket_putdatas:504
20180511 163111.651 (1230759744)     (4)> Socket_writev:428
20180511 163111.651 (1230759744)     (4)< Socket_writev:480 (230)
20180511 163111.651 (1230759744)    (3)< Socket_putdatas:552 (0)
20180511 163111.651 WEBSOCKET_IN_PROGRESS
20180511 163111.651 (1230759744)    (3)> MQTTClient_waitfor:1897
20180511 163111.651 (1230759744)     (4)> MQTTClient_cycle:1815
20180511 163111.651 (1230759744)      (5)> Socket_getReadySocket:239
20180511 163111.651 (1230759744)       (6)> Socket_continueWrites:929
20180511 163111.651 (1230759744)       (6)< Socket_continueWrites:953 (0)
20180511 163111.651 (1230759744)       (6)> isReady:215
20180511 163111.651 (1230759744)       (6)< isReady:220 (1)
20180511 163111.651 (1230759744)      (5)< Socket_getReadySocket:311 (3)
20180511 163111.651 (1230759744)      (5)> Socket_getdata:365
20180511 163111.651 (1230759744)       (6)> SocketBuffer_getQueuedData:163
20180511 163111.651 (1230759744)       (6)< SocketBuffer_getQueuedData:188
20180511 163111.651 (1230759744)       (6)> SocketBuffer_complete:263
20180511 163111.651 (1230759744)       (6)< SocketBuffer_complete:273
20180511 163111.656 (1230759744)      (5)< Socket_getdata:399
20180511 163111.656 (1230759744)      (5)> Socket_getdata:365
20180511 163111.656 (1230759744)       (6)> SocketBuffer_getQueuedData:163
20180511 163111.656 (1230759744)       (6)< SocketBuffer_getQueuedData:188
20180511 163111.656 (1230759744)       (6)> SocketBuffer_interrupted:236
20180511 163111.656 (1230759744)       (6)< SocketBuffer_interrupted:252
20180511 163111.656 (1230759744)      (5)< Socket_getdata:399
20180511 163111.656 WebSocket connection upgraded
20180511 163111.656 (1230759744)      (5)> Socket_getdata:365
20180511 163111.656 (1230759744)       (6)> SocketBuffer_complete:263
20180511 163111.656 (1230759744)       (6)< SocketBuffer_complete:273
20180511 163111.656 (1230759744)      (5)< Socket_getdata:399
20180511 163111.656 (1230759744)      (5)> MQTTClient_retry:1795
20180511 163111.656 (1230759744)       (6)> MQTTProtocol_retry:644
20180511 163111.656 (1230759744)       (6)< MQTTProtocol_retry:663
20180511 163111.656 (1230759744)      (5)< MQTTClient_retry:1805
20180511 163111.656 (1230759744)     (4)< MQTTClient_cycle:1886 (1)
20180511 163111.656 (1230759744)    (3)< MQTTClient_waitfor:1986 (1)
20180511 163111.656 (1230759744)    (3)> MQTTPacket_send_connect:51
20180511 163111.656 (1230759744)     (4)> MQTTPacket_send:176
20180511 163111.656 (1230759744)      (5)> MQTTPacket_encode:264
20180511 163111.656 (1230759744)      (5)< MQTTPacket_encode:274 (1)
20180511 163111.656 (1230759744)      (5)> Socket_putdatas:504
20180511 163111.656 (1230759744)       (6)> Socket_writev:428
20180511 163111.656 (1230759744)       (6)< Socket_writev:480 (25)
20180511 163111.656 (1230759744)      (5)< Socket_putdatas:552 (0)
20180511 163111.656 (1230759744)     (4)< MQTTPacket_send:201 (0)
20180511 163111.656 3 xxx -> CONNECT cleansession: 1 (0)
20180511 163111.656 (1230759744)    (3)< MQTTPacket_send_connect:109 (0)
20180511 163111.656 WAIT_FOR_CONNACK
20180511 163111.656 calling MQTTClient_waitfor(), millisecsTimeout=30000, MQTTClient_elapsed(start)=106
20180511 163111.656 (1230759744)    (3)> MQTTClient_waitfor:1897
20180511 163111.656 (1230759744)     (4)> MQTTClient_cycle:1815
20180511 163111.656 (1230759744)      (5)> Socket_getReadySocket:239
20180511 163111.656 (1230759744)       (6)> Socket_continueWrites:929
20180511 163111.656 (1230759744)       (6)< Socket_continueWrites:953 (0)
20180511 163111.656 (1230759744)       (6)> isReady:215
20180511 163111.656 (1230759744)       (6)< isReady:220 (1)
20180511 163111.656 (1230759744)      (5)< Socket_getReadySocket:311 (3)
20180511 163111.656 (1230759744)      (5)> MQTTPacket_Factory:108
20180511 163111.661 (1230759744)       (6)> Socket_getdata:365
20180511 163111.661 (1230759744)        (7)> SocketBuffer_getQueuedData:163
20180511 163111.661 (1230759744)        (7)< SocketBuffer_getQueuedData:188
20180511 163111.661 (1230759744)        (7)> SocketBuffer_complete:263
20180511 163111.661 (1230759744)        (7)< SocketBuffer_complete:273
20180511 163111.661 (1230759744)       (6)< Socket_getdata:399
20180511 163111.661 (1230759744)       (6)> Socket_getdata:365
20180511 163111.661 (1230759744)        (7)> SocketBuffer_getQueuedData:163
20180511 163111.661 (1230759744)        (7)< SocketBuffer_getQueuedData:188
20180511 163111.661 (1230759744)        (7)> SocketBuffer_complete:263
20180511 163111.661 (1230759744)        (7)< SocketBuffer_complete:273
20180511 163111.661 (1230759744)       (6)< Socket_getdata:399
20180511 163111.661 (1230759744)       (6)> Socket_getdata:365
20180511 163111.661 (1230759744)        (7)> SocketBuffer_complete:263
20180511 163111.661 (1230759744)        (7)< SocketBuffer_complete:273
20180511 163111.661 (1230759744)       (6)< Socket_getdata:399
20180511 163111.661 (1230759744)       (6)> MQTTPacket_decode:293
20180511 163111.661 (1230759744)       (6)< MQTTPacket_decode:309 (0)

This is where things go awry compared against the log hitting ws://test.mosquitto.org:8080, which works OK.

**20180511 163111.661 (1230759744)      (5)< MQTTPacket_Factory:156 (-22)**
20180511 163111.661 (1230759744)      (5)> MQTTClient_retry:1795
20180511 163111.661 (1230759744)       (6)> MQTTProtocol_retry:644
20180511 163111.661 (1230759744)       (6)< MQTTProtocol_retry:663
20180511 163111.661 (1230759744)      (5)< MQTTClient_retry:1805
20180511 163111.661 (1230759744)     (4)< MQTTClient_cycle:1886 (0)
20180511 163111.661 (1230759744)     (4)> MQTTClient_cycle:1815
20180511 163111.661 (1230759744)      (5)> Socket_getReadySocket:239
20180511 163111.661 (1230759744)       (6)> Socket_continueWrites:929
20180511 163111.661 (1230759744)       (6)< Socket_continueWrites:953 (0)
20180511 163111.661 (1230759744)       (6)> isReady:215
20180511 163111.661 (1230759744)       (6)< isReady:220 (1)
20180511 163111.661 (1230759744)      (5)< Socket_getReadySocket:311 (3)
20180511 163111.661 (1230759744)      (5)> MQTTPacket_Factory:108
20180511 163111.661 (1230759744)      (5)< MQTTPacket_Factory:156 (-1)
20180511 163111.661 (1230759744)      (5)> MQTTClient_retry:1795
20180511 163111.661 (1230759744)       (6)> MQTTProtocol_retry:644
20180511 163111.661 (1230759744)       (6)< MQTTProtocol_retry:663
20180511 163111.661 (1230759744)      (5)< MQTTClient_retry:1805
20180511 163111.661 (1230759744)     (4)< MQTTClient_cycle:1886 (-1)
20180511 163111.661 (1230759744)    (3)< MQTTClient_waitfor:1986 (-1)
20180511 163111.661 MQTTClient_waitfor() called, pack is NULL, returning SOCKET_ERROR
20180511 163111.661 (1230759744)    (3)> MQTTClient_disconnect1:1386
20180511 163111.661 (1230759744)     (4)> MQTTClient_closeSession:788
20180511 163111.661 (1230759744)      (5)> Socket_putdatas:504
20180511 163111.661 (1230759744)       (6)> Socket_writev:428
20180511 163111.661 (1230759744)       (6)< Socket_writev:480 (4)
20180511 163111.661 (1230759744)      (5)< Socket_putdatas:552 (0)
20180511 163111.661 (1230759744)      (5)> Socket_close:615
20180511 163111.661 (1230759744)       (6)> Socket_close_only:589
20180511 163111.661 (1230759744)       (6)< Socket_close_only:603 (0)
20180511 163111.661 (1230759744)       (6)> Socket_abortWrite:896
20180511 163111.661 (1230759744)       (6)< Socket_abortWrite:914 (0)
20180511 163111.661 (1230759744)       (6)> SocketBuffer_cleanup:136
20180511 163111.661 (1230759744)       (6)< SocketBuffer_cleanup:148
20180511 163111.661 Removed socket 3
20180511 163111.661 (1230759744)      (5)< Socket_close:642
20180511 163111.661 (1230759744)      (5)> MQTTClient_cleanSession:821
20180511 163111.661 (1230759744)       (6)> MQTTPersistence_clear:159
20180511 163111.661 (1230759744)       (6)< MQTTPersistence_clear:163 (0)
20180511 163111.661 (1230759744)       (6)> MQTTProtocol_emptyMessageList:726
20180511 163111.661 (1230759744)       (6)< MQTTProtocol_emptyMessageList:733
20180511 163111.662 (1230759744)       (6)> MQTTProtocol_emptyMessageList:726
20180511 163111.662 (1230759744)       (6)< MQTTProtocol_emptyMessageList:733
20180511 163111.662 (1230759744)       (6)> MQTTClient_emptyMessageQueue:444
20180511 163111.662 (1230759744)       (6)< MQTTClient_emptyMessageQueue:458
20180511 163111.662 (1230759744)      (5)< MQTTClient_cleanSession:829 (0)
20180511 163111.662 (1230759744)     (4)< MQTTClient_closeSession:813
20180511 163111.662 (1230759744)     (4)> MQTTClient_stop:722
20180511 163111.662 (1230759744)     (4)< MQTTClient_stop:757 (0)
20180511 163111.662 (1230759744)    (3)< MQTTClient_disconnect1:1430 (0)
20180511 163111.662 (1230759744)   (2)< MQTTClient_connectURIVersion:1108 (-1)
20180511 163111.662 (1230759744)  (1)< MQTTClient_connectURI:1262 (-1)
20180511 163111.662 (1230759744) (0)< MQTTClient_connect:1371 (-1)
myconnect: Failed to connect, return code -1

@icraggs icraggs merged commit 73cc3ea into eclipse:develop May 24, 2018

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@fpagliughi

This comment has been minimized.

Copy link
Contributor

fpagliughi commented May 24, 2018

Nice!

@lt-holman lt-holman deleted the lt-holman:develop branch May 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.