HTTPS client is here for the Photon! - by the Team


I’m having some trouble with this library. Curious if others have as well. It keeps putting my Photon into “flashing red” (hard fault) state. Originally I thought it was a problem with my code, but I built the “glowfish-post-test” app, with no changes other than inserting my credentials, and it also puts the Photon into a hard fault.

With the glowfish-post-test, the last lines of the trace are:

HttpClient>	Done before full len 
HttpClient>	Done before full len 
Received: 0
FAIL: No HTTP Response
httpsClientConnection Returned -12
free memory: 0

So it looks like it’s running out of memory? Is that example code working for anyone else? (Note, it didn’t build until I added the JSON library and #include).

With my own code, which is extremely similar to the above, but has a different endpoint and payload, I get errors more along the lines of:

free memory 3: 38420
FAIL: No HTTP Response
<loop runs again>
New Client Session Failed: Exiting


If you are running 0.4.6 it might be an issue with the underlying TCP stack.
You could either try to revert to 0.4.5, wait for 0.4.7 or try the fix in the current develop branch for local building.


Hi @sharding,

It is a known problem with httpsclient-particle. The problem comes from tcp packets not making back within the httpsclient timeout. Which is currently set to 4sec (I was shocked to see that this isn’t enough in some cases, but this happens). Increasing this number should help. This in itself wouldn’t be a problem, if there is a huge amount of memory available on the photon (to reallocate all the SSL buffers). You have to understand that these buffers are static, and there is still some memory allocation code that needs a clean up in MatrixSSL!

However, that being said, if you leave the client running with the red flashes, it reboots and the whole code runs again. It just so happens that the glowfish and timeapi examples run for a while (hours) once the connection is established before an event like this occurs again. Tested with firmware 0.4.5 at least. I should definitely play around with the timeout more.

I am very happy that the library is being tried out and used. This gives us an incentive to dig in deeper and fix more problems with the code. And as always, have a look at the library (at least the httpsclient-particle.cpp) and feel free to make suggestions.



Thanks @jersey99. I’m also a little surprised that a 4 second timeout isn’t enough in this case. I’ve seen many situations in which it wouldn’t be enough, but this shouldn’t be one of them (fast, low-latency network; solid wifi signal; fast service on the other end). Especially since it seems to happen 100% of the time. But I’ll try tweaking it and seeing if that helps.


Hi @michaelT! … such a great contribution! … thanks!. is there any guide/tutorial covering all issues related to httpsclient-particle library, apart from the provided examples? … that could be very useful for non-experts developers as me in order to use it for their own projects.


Hi @jersey99 … i’m thinking about using this httpsclient to implement a request from a photon device to a secure server, equivalent to the following in curl, and that as far as i know, can not be directly implement by using just webhooks.

$ curl -XPOST 'https://xxx
-i -L
-H “Authorization: Bearer xxx”
-H “Content-Type: xxx”
–data-binary “

just to know if this task deserves the time and effort it could take for a non-expert like me …would it be possible to implement this request by using this https client? any comment is welcome. thanks!


Hi @Maxime … when i tried to compile the example “glowfish-post-test.cpp” on the web IDE, i obtained the following errors (edited):

glowfish-post-test.cpp:52:3: error: ‘StaticJsonBuffer’ was not declared in this scope
glowfish-post-test.cpp:52:34: error: ‘glowfishJson’ was not declared in this scope
glowfish-post-test.cpp:53:3: error: ‘JsonObject’ was not declared in this scope
glowfish-post-test.cpp:53:15: error: ‘top’ was not declared in this scope
glowfish-post-test.cpp:55:15: error: ‘data_set’ was not declared in this scope
glowfish-post-test.cpp:58:3: error: ‘JsonArray’ was not declared in this scope
glowfish-post-test.cpp:58:14: error: ‘freememJ’ was not declared in this scope
glowfish-post-test.cpp:60:14: error: ‘timeup’ was not declared in this scope

was not the same for you? thanks


@fbt you need to add the JSON library to the app to get that one to compile. I ran into the same problem initially.


thanks a lot @sharding! best regards


Are you using this library?


Does anyone using this library with AWS API Gateway? We are having trouble at this point. The request goes through the API Gateway but the query string is missing before inserting to lambda via Mapping template.



Do you have a copy of the request? Usually the query string goes as an argument to the function httpsclientSetup.


Hi all,

I have this library working (which is an absolute success btw @jersey99 ) and can see my server’s response in the serial console, but can someone tell me how to extract the message body?



Hi @dan.s,

Did you manage to extract your data? Basically, copying to another buffer at Line 459 of httpsclient-particle.cpp should do the job. Let me know if you took a stab at it. Else, I will add it on my list.



Hi @jersey99, I have not had any luck modifying your library, I get an Uncaught TypeError when trying to compile using the Particle Dev package for Atom.

It shouldn’t be too hard though right? Add the following code:

  • unsigned char * received_msg to httpsClientConnection input
  • received_msg += g_buf[i]; to the loop at line 459

Or am I missing something?



What is the simplest way to do a GET on a page? Simple straight forward solution. Would love if it was some how a 1 liner.


I can not get the examples to work. My photon ends up crapping out with the dreaded red flash!

Opening serial monitor for com port: "/dev/cu.usbmodem1451"
Using 2048 bit RSA private key
Keys Loaded
New Session key!:
free memory: 38676
free memory 3: 38676
FAIL: No HTTP Response
free memory: 38676


GET - All you really need to do is change “POST” to “GET” in the header string. Line 16 of the timetest-test.cpp example shows what a GET looks like.

Red flash of death - Hmmmmm. I’m not sure what’s going there. Looks like a connectivity issue. Is the photon otherwise connecting ok to the network?


Ok, it seems like I’ve got it somewhat working with the time api example. POssibly a flaky internet on my behalf.

I think the red flash was from out of memory… possibly too long response times?


Hi there, what’s the update on this library?

@jersey99, I think I can give the library a bit of input.
Can I PM you for more info?