CSecureSocket Recv/RecvOneOrMore gives no data.
| Thu, 2007-08-16 09:16 | |
|
I'm in the process of implementing a solution which requires SSL. CSecureSocket is the way to go, but I have one major issue; Recv and RecvOneOrMore fails to deliver data to the application. I've tested against an HTTPS server, and the request is received by the server, and a response is returned; I just cannot access it. ...On completion, it calls RunL, like it should, and an async. request is sent: m_iSecureSocket->CancelAll();This also calls RunL on completion. I now start to listen for the server's response: m_iInputBuf.SetMax();RunL is never called if using RecvOneOrMore, or if using Recv, called when the server closes the socket 10 minutes later, and nothing has passed through the CSecureSocket to the receiving buffer. iError = m_iSocket.GetOpt( KSOReadBytesPending, KSOLSocket, iPendingData );The question is, how can I get this data, when Recv and RecvOneOrMore never yield anything? |
|






Forum posts: 162
Hi JensJ,
Very strange... Couple of points:
m_iSecureSocket->SetOpt(KSoSSLDomainName,KSolInetSSL, iAddress );seems to me an unnecessary call.Why are you calling
m_iSecureSocket->CancelAll();? Seems redundant.RecvOneOrMoreshould just work! However, you need to be careful about usingRecv. The legendary problem with Recv is, it only completes when the amount of data received is equal to the MaxLength of the descriptor passed in, so if your server returned 10 bytes of data, but the max length of the descriptor passed in is 20, Recv will hang.Apart from that, I've got nothing for you, yet. Also I hope the code you posted was some sort of psudo code, because its missing error checking
http://www.tanzim.co.uk
Forum posts: 6
Hi maxxxpayne,
Thanks for your reply, the posted code is partial grabs from the source.
m_iSecureSocket->SetOpt(KSoSSLDomainName,KSolInetSSL, iAddress ); is needed for S60 3rd, to validate the host you're connecting against. If omitted, it will fail handshake with error code -7547 (read about it here)
CancelAll() I've found to be a rather useful, when making tests with RSocket, besides, at the times it's called the socket is idle, i.e. immediately after negotiating security, and when responding to received data, which ofcourse never happens on my CSecureSocket, but did on my RSocket tests.
I'm well aware of the pitfalls of Recv. When attempting with this, my receive buffer is a fraction of the amount pending in my RSocket. Both work with RSocket, but neither with CSecureSocket.
Basically the code is the same as in the Symbian example, with a few extra lines, like "KSoSSLDomainName" and resetting buffers and counters. Compinling the Symbian
example has the exact same result; receives but never delivers.
Forum posts: 1
Have you sorted it out?
When I issue RecvOneOrMore() and then CancelRecv and then another RecvOneOrMore the 2nd RecvOneOrMore never returns (even when I know the data is sent to the device) and I cannot even cancel it.
This does not happen when I use RSocket.
Cheers!
Forum posts: 6
Hi tymi,
No, I never got CSecureSocket to work so I had to abandon that approach.
I'm fairly certain that there must be some undocumented call to get the async SSL to work correctly. I believe this is what's used in the HTTP classes.
An alternative could be to make a from scratch implementation of the newest TLS/SSL protocols.
Due to time constraints, we had to switch to a HTTPS solution.
I think I read about an OpenSSL implementation for Symbian, but with some limitations on licensing that makes it less viable for comercial applications.
Kindly,
Jens
Forum posts: 45
Hi JensJ,
we are aslo facing the same issue on Recv/RecvOneOrMore,but ours is bit different case.
we are using SSL for downloading two or more files,so we are able to download first one
succefully but when we try to download second file we are getting the above mentined problem,
That we are not receiving anything in the buffer after Recv() call.
did you get any solution for the same.
Thanks in advance.
Satya
NEWBIE OF SYMBIAN
Forum posts: 6
Hi tiger4mobile,
I never got mine to work, as stated above, and it's about a year ago so the exact details are a little hazy.
If you're managing to get the first file streamed down, but not the second, I'll assume that you issue a request for the second file after having received the first.
Perhaps you're missing a cancellation in order to get it to reset its receive data state.
You could try to omit the SSL/TLS on both server and client to see if it's an issue with your code or the CSecureSocket component. The regular CSocket seemed to work just fine for me, doing 2-way communications.
Kindly,
Jens
Forum posts: 45
Hi JansJ,
Thanks for your early reply.
we are calling cancelall on CSecuresocket after streaming first file but still we are not getting the data on Recv() for second file streaming.
what may be the reason..??
Thanks in advance.
Regards
Satya
NEWBIE OF SYMBIAN
Forum posts: 45
Hi jansJ,
When we call Recv() second file streaming its returning -36(KErrDisconneted),
i tried with RenegotiateHandshake() to get connected again but its not returning anything.
Do You have any idea how to get connection again??
Regards
Satya
NEWBIE OF SYMBIAN
Forum posts: 6
Hi,
That sounds like a HTTP server. The server closes the socket after it has sent its payload; that's the standard HTTP way of doing a transaction. One request&response per connection, and then discard it.
You'll need to make a new connection afterwards to get the next file.
Kindly,
Jens
Forum posts: 99
I agree with JensJ . If thats a HTTP Server make a fresh request again for the second download.
Shashi Kiran G M