Weblink over Win32 based C++ server

H Hayden Yates 2 weeks 3 days ago
56 1 0

Hi, we are trying to create a print server with Zebra's Weblink protocol using a C++ server and any relevant APIs and were wanting to see if there is any other documentation/resources to assist in this.


So far I have attempted this using HTTP Server API and have been able to accept the initial upgrade request and complete the handshake but after that I start running into two main issues. First issue being that even though the Zebra printer says the connection was successful, it then proceeds to ping pong on the network as expected but after three minutes the client closes the connection with code 1002 and error of "Read failed with an unexpected error" despite nothing being sent or received programmatically with the server since the handshake. Also, even though the connection was successful I do not receive any follow-up discovery packet with the printer info like we are supposed to - or at least I'm not having anything hit HttpReceiveHttpRequest to even try to decode as a discovery packet.


The next major issue is that I am not finding any way to push data to the printer at this point; the HTTP Server API just doesn't seem built for this sort of nonstandard approach and I have tried the WebSocket Protocol Component API as well but with no luck. I tried piggybacking off of the initial handshake request ID as well as ID of 0 to send the JSON command to open the raw channel but the printer seems to ignore it completely without any sort of error being logged on the printer or anything thrown by the HttpSendHttpResponse call. When trying to use WebSocket Protocol Component API instead, I only get exit code 0x8000000E "A method was called at an unexpected time" when attempting anything using that API so I am not sure what exactly is missing from that approach since I'm finding even less documentation for standalone server programming with that API.


I have been able to get a solution to work using the .NET WebSocket API but we would like to have it handled on our Win32 C++ side so that we can utilize other components of our solution, so I have been trying to replicate my approach into C++ as closely as possible but I am now blocked by those two issues and would appreciate any help or direction with where to go from here.

Environment info:
- Running C++ server on Windows 10 Pro
- Testing against Zebra ZD621

Please register or login to post a reply

1 Replies

E Ethel Lara
  1. HTTP Server API: Since you've already attempted to use the HTTP Server API and encountered issues, it's worth revisiting your implementation to ensure that you're handling the WebSocket upgrade request correctly and maintaining the WebSocket connection according to the protocol specifications. Check that you're sending appropriate WebSocket frames and handling timeouts properly.
  2. Discovery Packets: If you're not receiving the expected discovery packets from the printer, double-check that your server is listening on the correct network interface and port, and that it's able to receive UDP broadcast packets from the printer. Ensure that your server is not being blocked by any firewalls or network settings that might prevent it from receiving these packets.
  3. Pushing Data to the Printer: To push data to the printer after establishing the WebSocket connection, ensure that you're sending the correct JSON commands formatted according to the Weblink protocol specifications. Check that your server is properly encoding the JSON payload and sending it over the WebSocket connection.
CONTACT
Can’t find what you’re looking for?