These are chat archives for fanout/pushpin

9th
Aug 2018
Justin Karneges
@jkarneges
Aug 09 2018 01:34
Hi @picarsite , be sure to set the content type
Justin Karneges
@jkarneges
Aug 09 2018 01:41
for example, here's a curl request direct to the backend:
curl -i -H "Content-Type: application/websocket-events" --data-binary 'TEXT 5'$'\r'$'\n''hello'$'\r'$'\n' http://example.com/ws
yehosef
@yehosef_gitlab
Aug 09 2018 08:57
@jkarneges - thanks for the information. In our case the message volume is low (10-50 messages/s) just we need the connections open.
Adrian
@picarsite
Aug 09 2018 11:53
@jkarneges Thank you for your answer. I tried your suggestion but I just get the error "Error parsing WebSocket events."
Justin Karneges
@jkarneges
Aug 09 2018 15:17
@picarsite that means the request body isn't in the right format. see https://pushpin.org/docs/protocols/websocket-over-http/
you can also share your test and I can try to tell you where the problem is
Adrian
@picarsite
Aug 09 2018 16:09
@jkarneges I'm trying first to get it work with curl. I want to test my application without pushpin running in the background, is this even possible? My curl request: curl -i -H "Content-Type: application/websocket-events" --data-binary "OPEN\r\n" http://localhost:8080/api/websocket
Adrian
@picarsite
Aug 09 2018 16:59
I got it to work with Postman (OPEN) but I have to insert a new line in the body message, otherwise I get the same error like above. I can not get it to work with CURL. What I am doing wrong with CURL?
image.png
Strange, the same request in Postman does not work anymore. I did not change anything.
Adrian
@picarsite
Aug 09 2018 18:33
I found the reason why it is not workin anymore. When I do the linebreak in Postman, it does not work but when I do the linebreak in Notepad++ and copy it to Postman, the OPEN request works again in Postman. Enabling all hidden characters in Notepad++ and comparing both messages (created in Notepad++ and the one copied out of Postman), they look the same.
image.png
But how can I get it to work in CURL? It seems that \r\n is the problem which should the the linebreak.
Adrian
@picarsite
Aug 09 2018 19:08
It looks like linebreaks in Windows CMD are the problem.
Adrian
@picarsite
Aug 09 2018 19:14
It was driving me crazy but I found a solution for the curl problem under windows.
I am sure this is something many windows users will get. Advice: Do not use the curl for windows which you can download at their website. Use the git bash which comes with curl and many other nice linux tools.
Adrian
@picarsite
Aug 09 2018 19:21
curl -i -H "Content-Type: application/websocket-events" --data-binary $'OPEN\r\n' http://localhost:8080/api/websocket runs in Git Bash but not in the command line of windows. Under the normal command line this command throws "Error parsing WebSocket events.". The same command in Git Bash works perfectly and returns "OPEN".
Here is the proof:
image.png
Adrian
@picarsite
Aug 09 2018 19:28
Learned something new today. Now I can try to write some tests for my app :)
Adrian
@picarsite
Aug 09 2018 19:59
Ok, I have a new problem. Now I want to send a message to my app. When I sent this command curl -i -H "Content-Type: application/websocket-events" --data-binary $'OPEN\r\nTEXT 0x20\r\n{ type: "login", value: "uuid" }\r\n' http://localhost:8080/api/websocket I get the following error Error: Read from empty buffer. at defineClass.isOpening.recvRaw