B4R Question HttpJob problem when using SSL connection

BertI

Member
Licensed User
Longtime User
Not sure if this a question or a bug... I have been trying to use HttpJob on an ESP8266 device to connect via a WiFi SSL socket. I'm aware that there is advice that this doesn't work with all servers, however I'm getting a specific type of error and wondered if anyone had any ideas what this might mean. An example Log is shown below (sorry just copy/paste - can someone also tell me the most appropriate way to insert Log output into my posts). This particular one tries to Post something to a local server which I know is implementing a working SSL server (though uses self-certified certificate). However I did also try Posting to an aws hosted site with same results. The code uses the standard HttpJob version 1.0 and I have no problems with various non SSL connections. The Abort happens during this point in the HttpJob code:

B4X:
        If sslsocket.ConnectHost(host, port) Then

Log output from example attempt:

trying to connect to: 192.168.0.4 port: 443 ssl: 1

Abort called

>>>stack>>>

ctx: cont
sp: 3fff40e0 end: 3fff4500 offset: 01b0
3fff4290: 00000000 00000000 3fff13e4 40223550
3fff42a0: 3fff0c80 3fff13e4 3fff13e4 40212f77
3fff42b0: 00000000 3fff4310 402184a0 3fff34e0
3fff42c0: 00000000 00000000 00000000 4021911b
3fff42d0: 00000000 3fff8304 3fff13e4 40211cb1
3fff42e0: 00003fff 00000d50 00000001 000000f4
3fff42f0: 00003fff 3fff13e4 3fff69c0 000000f4
3fff4300: 00003fff 3fff13e4 3fff69c0 402131e5
3fff4310: 4021b580 0302a8c0 4021b580 0302a8c0
3fff4320: 00000000 3fff69b8 00000066 4021aa9a
3fff4330: 00000000 3fff4340 00000066 4020fde5
3fff4340: 00000000 3fff69b8 00000066 40202fd3
3fff4350: 40266130 00000003 00003fff 00000066
3fff4360: 40266128 00000008 00000001 00000001
3fff4370: 00000000 3fff4300 00000000 40202c00
3fff4380: 00000000 3fff4300 00000000 00000000
3fff4390: 00000000 00000000 00000000 3fff1600
3fff43a0: 0000000b 3fff0004 3fff13d0 40204164
3fff43b0: 3fff6990 3fff4364 3fff6998 3fff6998
3fff43c0: 3fff16b0 000000ec 3fff126c 402037a5
3fff43d0: 3ffe863e 3fff2d01 00000000 40201d1c
3fff43e0: 3fff69a0 00000030 3fff126c 40201d1c
3fff43f0: 00000000 3fff68d4 3fff126c 40205b3a
3fff4400: 00000000 3fff3300 00000000 40219b00
3fff4410: 3ffe88bd 00000001 3ffe8882 40216001
3fff4420: 3ffe8873 00000001 3ffe865d 40201b01
3fff4430: 3ffe8851 00000601 3ffe8844 40218501
3fff4440: 3ffe883d 3fff2d01 3fff4450 40210002 <
3fff4450: 3fff4458 3fff68bc 3ffe8839 40213301
3fff4460: 3fff3341 00000006 402661cc 00000008
3fff4470: 3fff4458 00000000 4bc6a7f0 00000000
3fff4480: 00000000 3fff2fec 40100b40 3fff4538
3fff4490: 3fff126c 00000000 00000000 40205bdb
3fff44a0: 3fffdad0 00000000 3fff2e6c 40201354
3fff44b0: 3fffdad0 3fff51ec 3fff1290 4020267c
3fff44c0: 3fffdad0 3fff1298 3fff5224 402026e3
3fff44d0: 3fffdad0 00000000 3fff4508 402101d3
3fff44e0: feefeffe feefeffe feefeffe 40218550
3fff44f0: feefeffe feefeffe 3ffe8520 4010112d
<<<stack<<<

last failed alloc call: 4022357E(16709)

ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v8b899c12
~ld
 

BertI

Member
Licensed User
Longtime User
Same problem. I guess by this question the suggestion is that it has been known to work with https://www.google.com so something I must be missing? Does any part of the error report suggest anything do you know?

trying to connect to: www.google.com port: 443 ssl: 1

Abort called

>>>stack>>>


ctx: cont
sp: 3fff40e0 end: 3fff4500 offset: 01b0
3fff4290: 00000000 00000000 3fff13e4 40223528
3fff42a0: 3fff0c80 3fff13e4 3fff13e4 40212f4f
3fff42b0: 00000000 3fff4310 40218478 3fff34e0
3fff42c0: 00000000 00000000 00000000 402190f3
3fff42d0: 00000000 3fff8304 3fff13e4 40211c89
3fff42e0: 000001bb 00000d50 00000000 000000f4
3fff42f0: 000001bb 3fff13e4 3fff69c0 000000f4
3fff4300: 000001bb 3fff13e4 3fff69c0 402131bd
3fff4310: 4021b558 a4d33ad8 4021b558 a4d33ad8

etc...
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
google says it uses tls, not ssl 1. the error messages seem to imply your connection uses ssl 1
 
Upvote 0

BertI

Member
Licensed User
Longtime User
I think SSL is used as a generic term which includes the newer TLS methods. However the odd thing is that I have now tried Erel's example in rHttpUtils.zip (see https://www.b4x.com/android/forum/threads/module-rhttputils2-http-client.74785/) and this does seem to work fine with google. I did also try a simple download test rather than a Post (though it's the connection mechanism to the host that is throwing up the problem). So even using this in my code:

B4X:
private Sub test()
    HttpJob.Initialize("Example")
    HttpJob.Download("https://www.example.com")
End Sub

still results in the Abort called issue.

So I guess it must be some other aspect of my code that is causing this. Though I don't know what the error dump is telling me I wondered if its a memory issue. However I have StackBufferSize of 4100
 
Upvote 0

BertI

Member
Licensed User
Longtime User
Using the rHttpUtils example works fine both with the Google URL and my server. So it does look like something in my overall code is causing some issue or, rather, not interacting well with sslsocket. I mention the latter because the code appears to work fine with non ssl socket connections. So if I use http://www.google.com rather than https://www.google.com in the test sub of post #5 above, then I get no problems connecting and also receive a response to the download request.
 
Upvote 0

BertI

Member
Licensed User
Longtime User
Well my suspicions were eventually confirmed - all you have to do is check RAM availability before and after the sslsocket.ConnectHost statement and the difference is around 21K as compared to around 500 bytes with a non ssl connection. Which leaves me with a bit of a problem as I'm already down to around 15K prior to the call. That's a lot of pruning to try and do at this stage, boo hoo...
 
Upvote 0
Top