# HTTPS client is here for the Photon! - by the glowfi.sh Team

**URL:** <https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934>\
**Category:** Firmware\
**Created:** [September 24, 2015, 9:13pm UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934 "2015-09-24T21:13:19Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![sharding](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/sharding/32/7342_2.png) [@sharding](https://community.particle.io/u/sharding)\
**Post date:** [October 18, 2015, 5:08am UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/21 "2015-10-18T05:08:29Z")

</div>

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 
0
HttpClient>	Done before full len 
0
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:

```
matrixSslNewClientSession:1
free memory 3: 38420
FAIL: No HTTP Response
<loop runs again>
matrixSslNewClientSession:-10
New Client Session Failed: Exiting
```

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [October 18, 2015, 6:01am UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/22 "2015-10-18T06:01:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jersey99](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@jersey99](https://community.particle.io/u/jersey99)\
**Post date:** [October 18, 2015, 5:24pm UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/23 "2015-10-18T17:24:57Z")

</div>

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.

Cheers,  
@jersey99

---

<div class="post-metadata">

**Author:** ![sharding](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/sharding/32/7342_2.png) [@sharding](https://community.particle.io/u/sharding)\
**Post date:** [October 18, 2015, 6:14pm UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/24 "2015-10-18T18:14:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fbt](https://avatars.discourse-cdn.com/v4/letter/f/b9e5f3/32.png) [@fbt](https://community.particle.io/u/fbt)\
**Post date:** [October 19, 2015, 6:37pm UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/25 "2015-10-19T18:37:45Z")

</div>

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.  
thanks!

---

<div class="post-metadata">

**Author:** ![fbt](https://avatars.discourse-cdn.com/v4/letter/f/b9e5f3/32.png) [@fbt](https://community.particle.io/u/fbt)\
**Post date:** [October 19, 2015, 11:03pm UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/26 "2015-10-19T23:03:45Z")

</div>

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](https://xxx)   
-i -L   
-H “Authorization: Bearer xxx”   
-H “Content-Type: xxx”   
–data-binary “@file.xxx”

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!

---

<div class="post-metadata">

**Author:** ![fbt](https://avatars.discourse-cdn.com/v4/letter/f/b9e5f3/32.png) [@fbt](https://community.particle.io/u/fbt)\
**Post date:** [October 20, 2015, 12:42pm UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/27 "2015-10-20T12:42:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sharding](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/sharding/32/7342_2.png) [@sharding](https://community.particle.io/u/sharding)\
**Post date:** [October 20, 2015, 2:59pm UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/28 "2015-10-20T14:59:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fbt](https://avatars.discourse-cdn.com/v4/letter/f/b9e5f3/32.png) [@fbt](https://community.particle.io/u/fbt)\
**Post date:** [October 20, 2015, 3:24pm UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/29 "2015-10-20T15:24:12Z")

</div>

thanks a lot @sharding! best regards

---

<div class="post-metadata">

**Author:** ![ericso](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@ericso](https://community.particle.io/u/ericso)\
**Post date:** [October 29, 2015, 1:44am UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/30 "2015-10-29T01:44:26Z")

</div>

Are you using this library? [https://github.com/bblanchon/ArduinoJson](https://github.com/bblanchon/ArduinoJson)

---

<div class="post-metadata">

**Author:** ![ericso](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@ericso](https://community.particle.io/u/ericso)\
**Post date:** [October 29, 2015, 1:46am UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/31 "2015-10-29T01:46:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jersey99](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@jersey99](https://community.particle.io/u/jersey99)\
**Post date:** [October 29, 2015, 3:29am UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/32 "2015-10-29T03:29:36Z")

</div>

@ericso

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

---

<div class="post-metadata">

**Author:** ![dan.s](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dan.s/32/24623_2.png) [@dan.s](https://community.particle.io/u/dan.s)\
**Post date:** [November 8, 2015, 7:15pm UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/33 "2015-11-08T19:15:03Z")

</div>

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?

Thanks!

---

<div class="post-metadata">

**Author:** ![jersey99](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@jersey99](https://community.particle.io/u/jersey99)\
**Post date:** [November 11, 2015, 8:13pm UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/34 "2015-11-11T20:13:56Z")

</div>

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.

jersey99

---

<div class="post-metadata">

**Author:** ![dan.s](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dan.s/32/24623_2.png) [@dan.s](https://community.particle.io/u/dan.s)\
**Post date:** [November 12, 2015, 1:18pm UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/35 "2015-11-12T13:18:35Z")

</div>

Hi @jersey99, I have not had any luck modifying your library, I get an [Uncaught TypeError](https://github.com/spark/spark-dev/issues/127) 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?

Thanks,  
Dan

---

<div class="post-metadata">

**Author:** ![dougM](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dougM](https://community.particle.io/u/dougM)\
**Post date:** [December 2, 2015, 5:54pm UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/36 "2015-12-02T17:54:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dougM](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dougM](https://community.particle.io/u/dougM)\
**Post date:** [December 3, 2015, 6:54pm UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/37 "2015-12-03T18:54:05Z")

</div>

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  
> matrixSslNewClientSession:1  
> free memory 3: 38676  
> FAIL: No HTTP Response  
> free memory: 38676

---

<div class="post-metadata">

**Author:** ![josec](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@josec](https://community.particle.io/u/josec)\
**Post date:** [December 3, 2015, 8:38pm UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/38 "2015-12-03T20:38:55Z")

</div>

GET - All you really need to do is change “POST” to “GET” in the header string. Line 16 of the [timetest-test.cpp example](https://github.com/glowfishAPI/httpsclient-particle/blob/master/firmware/examples/timeapi-test.cpp) 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?

---

<div class="post-metadata">

**Author:** ![dougM](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dougM](https://community.particle.io/u/dougM)\
**Post date:** [December 3, 2015, 9:13pm UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/39 "2015-12-03T21:13:45Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jhlink](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@jhlink](https://community.particle.io/u/jhlink)\
**Post date:** [December 3, 2015, 9:27pm UTC](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934/40 "2015-12-03T21:27:11Z")

</div>

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?

[Previous page](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934.md?page=1)

[Next page](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934.md?page=3)
