Hi All!
I have 2 problems with smartfox connection:
1. App crash when smartfox connection retry:
void SmartFox::SendHandshakeRequest(bool isReconnection)
{
boost::shared_ptr<HandshakeRequest> req (new HandshakeRequest(*this->Version(), isReconnection ? *sessionToken : "", *clientDetails));
Send(req);
}
sessionToken become NULL when smartfox try to reconnect.
2. Smartfox connect function does not respone anything when connection is closed by server side after idle time. The specific scenario is:
- App idle
- After idle time server close connection
- Client receive event Connection Lost
- Client call function connect to server again
- And then client does not receive any event after call connect function.
That my current connection problems, please help me! Thanks.
Crash when connection retry
Moderators: Lapo, Bax, MBagnati
-
- Posts: 6
- Joined: 14 Jan 2015, 05:53
Re: Crash when connection retry
We will shortly investigate issue #1.
About issue #2, after a disconnection you have to create a new SmartFox object, you can't reuse the existing one.
About issue #2, after a disconnection you have to create a new SmartFox object, you can't reuse the existing one.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Re: Crash when connection retry
Hi,
About the issue #1, please implement the following fix.
Open file SmartFox.cpp and move at the begin of method SmartFox::Reset()
Here, insert these statements
So, updated method will be
Let us know if it solves the crash
About the issue #1, please implement the following fix.
Open file SmartFox.cpp and move at the begin of method SmartFox::Reset()
Here, insert these statements
Code: Select all
if ((bitSwarm != NULL) && (bitSwarm->ReconnectionSeconds() > 0))
{
return;
}
So, updated method will be
Code: Select all
void SmartFox::Reset()
{
if ((bitSwarm != NULL) && (bitSwarm->ReconnectionSeconds() > 0))
{
return;
}
bbConnectionAttempt = 0;
...
...
...
Let us know if it solves the crash
-
- Posts: 6
- Joined: 14 Jan 2015, 05:53
Re: Crash when connection retry
Hi,
Thanks for your help, After apply this code the problem 1 is gone. But I have another issue with problem 2 when I dispose smartfox instance.
When I call dispose function of smartfox instance it happen others 2 problems:
- App crash at function processEvent()
for (iterator = events.begin() ; iterator < events.end(); iterator++)
{
boost::shared_ptr<BaseEvent> evt = *iterator;
Dispatcher()->DispatchEvent(evt); // Crash here
// Cleanup
CleanEventParams(evt);
}
- App lock at function dispose() of BitwarmClient
if (socket != NULL)
{
lockDispose.lock(); // App freeze here
boost::shared_ptr<ConnectionDelegate> delegateConnection = boost::shared_ptr<ConnectionDelegate>();
socket->OnConnect(delegateConnection);
boost::shared_ptr<ConnectionDelegate> delegateDisconnection = boost::shared_ptr<ConnectionDelegate>();
socket->OnDisconnect(delegateDisconnection);
boost::shared_ptr<OnDataDelegate> delegateOnData = boost::shared_ptr<OnDataDelegate>();
socket->OnData(delegateOnData);
boost::shared_ptr<OnErrorDelegate> delegateOnError = boost::shared_ptr<OnErrorDelegate>();
socket->OnError(delegateOnError);
lockDispose.unlock();
}
Please help me solve this issue, Thanks
Thanks for your help, After apply this code the problem 1 is gone. But I have another issue with problem 2 when I dispose smartfox instance.
When I call dispose function of smartfox instance it happen others 2 problems:
- App crash at function processEvent()
for (iterator = events.begin() ; iterator < events.end(); iterator++)
{
boost::shared_ptr<BaseEvent> evt = *iterator;
Dispatcher()->DispatchEvent(evt); // Crash here
// Cleanup
CleanEventParams(evt);
}
- App lock at function dispose() of BitwarmClient
if (socket != NULL)
{
lockDispose.lock(); // App freeze here
boost::shared_ptr<ConnectionDelegate> delegateConnection = boost::shared_ptr<ConnectionDelegate>();
socket->OnConnect(delegateConnection);
boost::shared_ptr<ConnectionDelegate> delegateDisconnection = boost::shared_ptr<ConnectionDelegate>();
socket->OnDisconnect(delegateDisconnection);
boost::shared_ptr<OnDataDelegate> delegateOnData = boost::shared_ptr<OnDataDelegate>();
socket->OnData(delegateOnData);
boost::shared_ptr<OnErrorDelegate> delegateOnError = boost::shared_ptr<OnErrorDelegate>();
socket->OnError(delegateOnError);
lockDispose.unlock();
}
Please help me solve this issue, Thanks
Re: Crash when connection retry
Hi,
I am not able to reproduce your crash.
Could you give me additional info about the context where you call Dispose?
Please take a look at SimpleChat sample. Are you able to get the crash using this sample?
In this sample the Dispose is called inside the OnDestroy of main window and, on my computer, I have not any crash.
Please, can you also check that you have called Disconnect method to terminate all I/O tasks before than Dispose? (see sample code above)
I am not able to reproduce your crash.
Could you give me additional info about the context where you call Dispose?
Please take a look at SimpleChat sample. Are you able to get the crash using this sample?
In this sample the Dispose is called inside the OnDestroy of main window and, on my computer, I have not any crash.
Code: Select all
void CMainFrame::OnDestroy()
{
if (m_ptrSmartFox != NULL)
{
m_ptrSmartFox->Disconnect();
m_ptrSmartFox->Dispose();
m_ptrSmartFox = NULL;
}
CFrameWndEx::OnDestroy();
}
Please, can you also check that you have called Disconnect method to terminate all I/O tasks before than Dispose? (see sample code above)
-
- Posts: 6
- Joined: 14 Jan 2015, 05:53
Re: Crash when connection retry
Hi!
I also use this code to check in case we have wifi on it work correctly, But in case wifi off app also freeze in dispose method.
if (smartFox)
{
CCLOG("disconnectToServer: smartFox->Dispose() start");
smartFox->Disconnect();
smartFox->Dispose(); // App freeze here when we don't have network connection (on mobile device wifi off, or out of wifi range)
CCLOG("disconnectToServer: smartFox->Dispose() end");
}
On PC I tested by disable network adapter.
Thanks for your response!
I also use this code to check in case we have wifi on it work correctly, But in case wifi off app also freeze in dispose method.
if (smartFox)
{
CCLOG("disconnectToServer: smartFox->Dispose() start");
smartFox->Disconnect();
smartFox->Dispose(); // App freeze here when we don't have network connection (on mobile device wifi off, or out of wifi range)
CCLOG("disconnectToServer: smartFox->Dispose() end");
}
On PC I tested by disable network adapter.
Thanks for your response!
Re: Crash when connection retry
Hi,
To investigate the issue, I have done these tests:
Test #1
I have disabled the wi-fi network card from Windows panel "Network Connections".
Then I have started the SimpleChat sample.
Of course, SimpleChat is not able to connect to SmartFox Server (because the wi-fi network is disabled), so after few seconds it shows the message "Timeout establishing connection with SmartFoxServer".
At this point I have terminated the SimpleChat application closing its main windows
Looking at the source code, I see that method CMainFrame::OnDestroy() is called and it is executed without any freeze (Smartfox Disconnect and Dispose functions called from OnDestroy are executed without freeze).
Test #2
My wi-fi network card is working.
I start the SimpleChat sample.
SimpleChat establishes the connection with SmartFoxServer by the IP channel and all is working.
At this point, I disable the wi-fi network card from Windows panel "Network Connections".
After a couple of seconds, SimpleChat detects the fault of the connection with SmartFoxServer and shows the login page.
I terminate the SimpleChat application closing its main windows
Looking at the source code, I see that method CMainFrame::OnDestroy() is called and it is executed without any freeze (Smartfox Disconnect and Dispose functions called from OnDestroy are executed without freeze).
Please, can you perform an additional test to help me to investigate the issue?
Can you use the SimpleChat sample to repeat the above tests to check the behaviour of login and disconnect when you disable your wi-fi card?
To investigate the issue, I have done these tests:
Test #1
I have disabled the wi-fi network card from Windows panel "Network Connections".
Then I have started the SimpleChat sample.
Of course, SimpleChat is not able to connect to SmartFox Server (because the wi-fi network is disabled), so after few seconds it shows the message "Timeout establishing connection with SmartFoxServer".
At this point I have terminated the SimpleChat application closing its main windows
Looking at the source code, I see that method CMainFrame::OnDestroy() is called and it is executed without any freeze (Smartfox Disconnect and Dispose functions called from OnDestroy are executed without freeze).
Test #2
My wi-fi network card is working.
I start the SimpleChat sample.
SimpleChat establishes the connection with SmartFoxServer by the IP channel and all is working.
At this point, I disable the wi-fi network card from Windows panel "Network Connections".
After a couple of seconds, SimpleChat detects the fault of the connection with SmartFoxServer and shows the login page.
I terminate the SimpleChat application closing its main windows
Looking at the source code, I see that method CMainFrame::OnDestroy() is called and it is executed without any freeze (Smartfox Disconnect and Dispose functions called from OnDestroy are executed without freeze).
Please, can you perform an additional test to help me to investigate the issue?
Can you use the SimpleChat sample to repeat the above tests to check the behaviour of login and disconnect when you disable your wi-fi card?
-
- Posts: 6
- Joined: 14 Jan 2015, 05:53
Re: Crash when connection retry
Thanks for your response my issue!
I have find out my problems. My app freeze because when connection lost i try to make new request to connect to server (at that time network adapter was disable) so that request is pending and block IO because smartfox have no event back when connection cannot establish. So I have to make counter to count down 10s to dispose smartfox instance. So that my app freeze at dispose function of smartfox.
My solution is: When connection lost I call function smartfox->disconnect(), and then smartfox->dispose(). And then I make new smartfox instance to reconnect to my server.
Thanks for your help very much!
I have find out my problems. My app freeze because when connection lost i try to make new request to connect to server (at that time network adapter was disable) so that request is pending and block IO because smartfox have no event back when connection cannot establish. So I have to make counter to count down 10s to dispose smartfox instance. So that my app freeze at dispose function of smartfox.
My solution is: When connection lost I call function smartfox->disconnect(), and then smartfox->dispose(). And then I make new smartfox instance to reconnect to my server.
Thanks for your help very much!
Who is online
Users browsing this forum: No registered users and 29 guests