Getting error KErrAbort (error code -39) when creating ssl connection
Hi Expert,
I am getting error KErrAbort (error code -39) when creating ssl connection , am using WikiSecureSocketEx.zip example for reference .
Please Help as soon as.
Looking forward positive response.
Re: Getting error KErrAbort (error code -39) when creating ssl connection
in general, you should provide a link to the original source, that way somebody could actually try understanding what you are doing.
Also, if you made any changes to any parts of code, you should really mention that.
also which platform you are building, and with which tools.
And you should mention whether you get this error in emulator, or in device (please also specify the device used)
And also it might help, if you could specify the line of code which after you get this error.
Re: Getting error KErrAbort (error code -39) when creating ssl connection
Hey Yucca,
I ma getting error at line User::LeaveIfError(iStatus.Int()); in below function called.
void CSecureSocketCore::MakePageRequestL() KErrNone
{
// The secure connection has now been made.
// Send a get request for the page.
User::LeaveIfError(iStatus.Int());
Re: Getting error KErrAbort (error code -39) when creating ssl connection
that part of code does not make any sense really.. Basically you would need to undestand teh code first, I assume that you have active object there, and you make a reguest, and then your RunL gets called.
when the RunL is called, then the iStatus.Int() would indicate possible error codes, so do see how you get to this function, and what is done there.
Then again, what else would be in this particular function ?
Re: Getting error KErrAbort (error code -39) when creating ssl connection
Hi Yucca Thanks, i added iSecureSocket->SetOpt(KSoSSLDomainName, KSolInetSSL, serverName);
after creating securesocket and now it is making connection and requesting for data but still
not able to open the web page.
iRcvBuffer.Length() is coming 0.
void CSecureSocketCore::ReadServerResponseL()
{
// Any error other than KErrEof means the test is a failure
if (iStatus!=KErrEof) User::LeaveIfError(iStatus.Int());
// Put the received data in the output file & reset the receive buffer
iTotalBytesRead += iRcvBuffer.Length();
// Case 1: error is KErrEof (message complete) or no data received, so stop
if ( ( iStatus==KErrEof ) || ( iRcvBuffer.Length() == 0 ) )
{
// Close the socket neatly
iState = EStopping;
iTimer.After( iStatus, 1000000 );
return;
}
Re: Getting error KErrAbort (error code -39) when creating ssl connection
Basically you would need to debug the codes, and see what is happening, and what is not. And as the problem is with data, so check that your other-end is indeed functioning OK as well, and the data is sent from there accordingly.
Also you should descipe problems in more details, the code does not have any reference to Web Browsers, so saying [B]but still not able to open the web page.[/B] sound a bit confusing to me.
Re: Getting error KErrAbort (error code -39) when creating ssl connection
[QUOTE=soni_neeraj;911308]Hi Yucca Thanks, i added iSecureSocket->SetOpt(KSoSSLDomainName, KSolInetSSL, serverName);[/QUOTE]That requires some elevated capability (perhaps WriteDeviceData) if I remember correctly. Have you checked its result code? Is it KErrNone?
Re: Getting error KErrAbort (error code -39) when creating ssl connection
[SIZE=5][B]but still not able to open the web page[[SIZE=5][/SIZE]/B][/SIZE] means : after connecting the socket , am trying to open web sit using that connection
Re: Getting error KErrAbort (error code -39) when creating ssl connection
Yes yucc , i am using WriteDeviceData capability, and i debug the code ,
the call flow of code is according to callback is below
ConnectL
MakeSecureConnectionL
MakePageRequestL
GetServerResponseL
ReadServerResponseL ->.> we are getting length code is 0 here :
below is the source code of example code:
/*
============================================================================
Name : SecureSocketCore.cpp
based on : [url]http://www.symbian.com/developer/techlib/v9.2docs/doc_source/examples/NetworkingEx/SSLExampleCode.guide.html#NetworkingEx%2eSSLExampleCode[/url]
Author : Konstantine; Company: Fishnest Ukraine Sebastopol
Version :
Support : [email]bluspan@gmail.com[/email]
Description : CSecureSocketCore implementation
============================================================================
*/
#include "SecureSocketCore.h"
// HTTP messages
_LIT8(KSimpleGet, "GET");
_LIT8(KNewLine, "\n");
CSecureSocketCore::CSecureSocketCore() : CActive( EPriorityStandard ), iSndBuffer(0,0), iRcvBuffer(0,0)
{
}
CSecureSocketCore* CSecureSocketCore::NewLC()
{
CSecureSocketCore* self = new ( ELeave ) CSecureSocketCore();
CleanupStack::PushL( self );
self->ConstructL();
return self;
}
CSecureSocketCore* CSecureSocketCore::NewL()
{
CSecureSocketCore* self = CSecureSocketCore::NewLC();
CleanupStack::Pop(); // self;
return self;
}
void CSecureSocketCore::ConstructL()
{
//== konstantine_entrance : mycode myinitialization
iPort = 443;
//iPort = 5222;
User::LeaveIfError( iSocketServer.Connect() );
iSndBuffer.Set((TUint8*)User::AllocL(256),0,256);
iRcvBuffer.Set((TUint8*)User::AllocL(256),0,256);
//== <- my
User::LeaveIfError( iTimer.CreateLocal() ); // Initialize timer
CActiveScheduler::Add( this ); // Add to scheduler
}
CSecureSocketCore::~CSecureSocketCore()
{
Cancel(); // Cancel any request, if outstanding
iTimer.Close(); // Destroy the RTimer object
delete (void*)iSndBuffer.Ptr();
delete (void*)iRcvBuffer.Ptr();
//CActiveScheduler::Stop();
// Delete instance variables if any
}
void CSecureSocketCore::DoCancel()
{
iTimer.Cancel();
}
void CSecureSocketCore::StartL( TTimeIntervalMicroSeconds32 aDelay )
{
Cancel(); // Cancel any request, just to be sure
//iState = EUninitialized;
iState = EMakingSecureConnection;
iTimer.After( iStatus, aDelay ); // Set for later
SetActive(); // Tell scheduler a request is active
}
void CSecureSocketCore::RunL()
{
if ( iState == EMakingSecureConnection) {
MakeSecureConnectionL();
iState = EMakingPageRequest;
iRBufConsoleObserver->AppendToConsole(_L("Making Secure Connection\n"));
}
else if ( iState == EMakingPageRequest) {
MakePageRequestL();
iState = EGettingServerResponse;
iRBufConsoleObserver->AppendToConsole(_L("Making Page Request\n"));
}
else if ( iState == EGettingServerResponse) {
GetServerResponseL();
iState = EDataReceived;
iRBufConsoleObserver->AppendToConsole(_L("Get Server Response\n"));
}
else if ( iState == EDataReceived) {
ReadServerResponseL();
}
else if ( iState == EStopping) {
ConnectionStop();
iState = EStopped;
iRBufConsoleObserver->AppendToConsole(_L("Stop Connection\n"));
iRBufConsoleObserver->ShowConsole();
}
else if ( iState != EError )
{
// Do something
}
//iTimer.After( iStatus, 1000000 ); // Set for 1 sec later
if (iState != EStopped)
SetActive(); // Tell scheduler a request is active
}
TInt CSecureSocketCore::RunError( TInt aError )
{
return aError;
}
// ---! Secure connection !---
void CSecureSocketCore::ConnectL()
{
iSndBuffer.SetLength( 0 );
iRcvBuffer.SetLength( 0 );
iTotalBytesRead = 0;
// _LIT( KIPAddress, "63.245.209.11");
_LIT( KIPAddress, "195.211.49.6");
// _LIT( KIPAddress, "o.nimbuzz.com");
// _LIT( KIPAddress, "195.211.49.18");
// 192.168.58.135
// _LIT( KIPAddress, "209.207.221.16");
//195.211.49.6
// 209.207.221.16
// _LIT( KIPAddress, "192.168.58.135");
// 195.211.49.16
// 195.211.49.6
//==konstantine_entrance : mycode
// from Chat example
TInetAddr addr;
TUint32 aAddr;
iState = EMakingSecureConnection;
if ( addr.Input( KIPAddress ) == KErrNone )
{
// server name is already a valid ip address
aAddr = addr.Address();
iAddress.SetPort( iPort );
iAddress.SetAddress( aAddr );
iAddress.SetFamily( KAfInet );
// Open a TCP socket
User::LeaveIfError( iSocket.Open( iSocketServer,
KAfInet,
KSockStream,
KProtocolInetTcp ) );
// Initiate socket connection
iSocket.Connect( iAddress, iStatus );
SetActive();
//CActiveScheduler::Start();
//User::LeaveIfError(iStatus.Int()); // errors caught by RunError()
}
}
void CSecureSocketCore::MakeSecureConnectionL()
{
User::LeaveIfError(iStatus.Int()); // errors caught by RunError()
TBufC8<32> servername(_L8("195.211.49.6"));
// TBufC8<32> servername(_L8("195.211.49.18"));
// TBufC8<32> servername(_L8("o.nimbuzz.com"));
// TBufC8<32> servername(_L8("63.245.209.11"));
//
// iTlsSocket = CSecureSocket::NewL( iSocket, _L("SSL3.0"));
iTlsSocket = CSecureSocket::NewL( iSocket, _L("SSL3.0"));
iTlsSocket->SetOpt(KSoSSLDomainName, KSolInetSSL, servername);
iTlsSocket->FlushSessionCache();
// start the handshake
iTlsSocket->StartClientHandshake( iStatus );
//SetActive();
}
void CSecureSocketCore::MakePageRequestL()
{
/* // The secure connection has now been made.
// Send a get request for the page.
User::LeaveIfError(iStatus.Int());
// _LIT8( KPage , "https://mozilla.org");
_LIT8( KPage , "https://nimbuzz.com");
// Create a GET request
iSndBuffer+=KSimpleGet;
iSndBuffer+=KPage();
iSndBuffer+=KNewLine;
// Send the request
iTlsSocket->Send( iSndBuffer, iStatus, iBytesSent );*/
User::LeaveIfError(iStatus.Int());
_LIT8( KPage,"http://www.nimbuzz.com");
// Create a GET request
iSndBuffer+=KSimpleGet; // "GET "
iSndBuffer+=KPage();
iSndBuffer+=KNewLine; // "\n"
// Send the request
iTlsSocket->Send( iSndBuffer, iStatus, iBytesSent );
}
void CSecureSocketCore::GetServerResponseL()
{
// The get request has been sent, can now try and receive the data
User::LeaveIfError(iStatus.Int());
TBuf8<2> buf;
User::LeaveIfError(iTlsSocket->CurrentCipherSuite( buf ));
// Print the protocol version string
TBuf<32> protocol;
User::LeaveIfError(iTlsSocket->Protocol( protocol ));
// Print info about the server's certificate
const CX509Certificate *servCert = iTlsSocket->ServerCert();
// Read asynchonously-returns when buffer full
iTlsSocket->Recv( iRcvBuffer, iStatus );
}
void CSecureSocketCore::ReadServerResponseL()
{
// Any error other than KErrEof means the test is a failure
if (iStatus!=KErrEof) User::LeaveIfError(iStatus.Int());
// Put the received data in the output file & reset the receive buffer
iTotalBytesRead += iRcvBuffer.Length();
// Case 1: error is KErrEof (message complete) or no data received, so stop
if ( ( iStatus==KErrEof ) || ( iRcvBuffer.Length() == 0 ) )
{
// Close the socket neatly
iState = EStopping;
iTimer.After( iStatus, 1000000 );
return;
}
// Case 2: there's more data to get from the server
iRcvBuffer.SetLength( 0 );
iState = EDataReceived;
iTlsSocket->Recv( iRcvBuffer, iStatus );
}
void CSecureSocketCore::ConnectionStop()
{
iSocket.CancelAll();
iTlsSocket->CancelAll();
iTlsSocket->Close();
delete iTlsSocket;
//iTlsSocket =0;
iSocket.Close();
//Cancel();
//iTimer.Cancel();
iSocketServer.Close();
//CActiveScheduler::Stop();
User::After( 1000000 );
}
void CSecureSocketCore::SetRBufConsoleObserver(CRBufConsoleObserver *aObserver)
{
iRBufConsoleObserver = aObserver;
}
//== <- my
Re: Getting error KErrAbort (error code -39) when creating ssl connection
KErrAbort comes because the server name you set in that SetOpt is probably incorrect, I do not think that it can be an IP number. 195.211.49.6 seems to correspond to nimbuzz.com, so try that name.
Otherwise what you create in MakePageRequestL is not a valid HTTP(S) request. The "http://host" is not part of the request, but the protocol version is. Check the related RFC or at least the simple examples on Wikipedia.
Re: Getting error KErrAbort (error code -39) when creating ssl connection
Thanks for ur reply:: i am getting same errro by using CSecuresocket example from wikipedia.
Re: Getting error KErrAbort (error code -39) when creating ssl connection
There are no CSecureSocket examples on Wikipedia. Also, I was talking about the HTTP part, [url]http://en.wikipedia.org/wiki/HTTP#Request_message[/url], the messaging part is the same for HTTPS.
Anyway, the HTTP part is not relevant as long as the connection can not be established. If nimbuzz.com or similar attempts do not work, you can try visiting the address from a regular browser ([url]https://195.211.49.6/[/url]) and checking its certificate, that may help.
Re: Getting error KErrAbort (error code -39) when creating ssl connection
Hi Am talking about WikiSecureSocketEx example.: it is also not working
Re: Getting error KErrAbort (error code -39) when creating ssl connection
It can not work if the SetOpt does not match with the server certificate.
Re: Getting error KErrAbort (error code -39) when creating ssl connection
so pls tell me how dose it match?