Test for open CoAP port on network - Macintosh

I have recently run into several situations where the WiFi network at a site does not have the required CoAP port(s) open. I try to explain what is required, but often get told, “We don’t stop anything” only to subsequently (after several hours) learn there actually is something blocking that port.

Is there a simple technique (via Terminal on my MacBook Pro) for checking to see if the required CoAP port is open? I can easily put my laptop on the subject WiFi network but currently don’t have a technique to see if I can make a connection to the Particle cloud via CoAP. I read somewhere recently that using telnet and specifying the URL and appropriate port # might be an approach.

I also don’t want to go through the hassle of pushing diagnostic software onto the Particle device. Proving the connection status via a laptop will be easier and more “trusted” by those unfamiliar with Particle.

On the Mac, to test for Photon/P1 access, I think this should work from a Terminal window:

nc device.spark.io 5683

You should get back some garbage characters like this immediately:

?ej|,ty?SW
??ZMA?"?(0??58'??)?C?^C

If you get no response or connection refused, then a firewall is probably blocking access.

It’s more difficult to check for Argon connectivity as it uses UDP.

I’ve tried that here in our offices where we have no trouble, but with no success. I assumed there was something getting in the way of that technique.

Actually, I tried both 5683 and 5684.

well…just tried it, again, and it worked to 5683

tom@ctm-macbook-pro ~ % nc -zv device.spark.io 5683
Connection to device.spark.io port 5683 [tcp/*] succeeded!

So…I should tell them I need UDP port 5684 open, since there’s an Argon at the location?

I haven’t found a good way to check the UDP port with nc, but yes, for the Argon UDP port 5684.

https://docs.particle.io/tutorials/device-cloud/introduction/#cloud-services-and-firewalls

Here’s the solution (you just need to add the -u flag to test for UDP):

tom@ctm-macbook-pro ~ % nc -zvu device.spark.io 5684
Connection to device.spark.io port 5684 [udp/*] succeeded!

It might be wise/helpful to post these tips for others who have faced similar challenges…organizations that insist things are open and you need an effective way to test.

I don’t think that works. You can put any port number in and it returns success, because success only indicates that the socket was created.

Also you should use this hostname instead for UDP on the Argon.

nc -uz 1.udp.particle.io 5684

well…darn! I thought we had it! :grinning:

But…I wonder if the port was blocked at a firewall type device, would the response be the same?