You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
}
The code work fine most of time.But sometimes, it does not, the application was blocked by apn_connect() accidentally, once a day recently.
Then I used the strace -p pid, just give a message blow:
read(39,
no more message.
And with the gdb attach the application process id, the message blow:
it looks like block at __read_nocancel().
So, after googling, I found the issues on stackoverflow: http://stackoverflow.com/questions/11835203/openssl-ssl-connect-blocks-forever-how-to-set-timeout
and I view the libcapn source code, the __apn_connect() doesn't use the SSL_CTX_set_timeout() or SSL_SESSION_set_timeout(), of course it may have no effect just like that guy said.
Following, I will try to add SSL_CTX_set_timeout() or SSL_SESSION_set_timeout() to the __apn_connect() fuction and test it works or not.
I suggest give a fuction whic like apn_connect_timeout so that it can be setted the timeout.
THX.
The text was updated successfully, but these errors were encountered:
@dungwinve I don't have time to try SSL_CTX_set_timeout() or SSL_SESSION_set_timeout() yet. I have just used the SIGALRM signal to interrupt the block, and it work well for two weeks now.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi, this is my code, what just use the sample http://libcapn.org/doc/html/send_push_8c-example.html code, a little different is use the apn_payload_add_custom_property_string() in some codition.
int32_t PushToApple(std::string& strIosToken, std::string& strMsg,int32_t nBadge,const char* pstrExt)
{
apn_payload_ctx_ref payload_ctx = NULL;
apn_ctx_ref ctx = NULL;
apn_error_ref error = NULL;
const char *cert_path = "apns-pro-cert.pem";
const char *key_path = "apns-pro-key-noenc.pem";
const char *push_message = strMsg.c_str();
const char *token = strIosToken.c_str();
time_t time_now = 0;
if(apn_init(&ctx, cert_path, key_path, NULL, &error) == APN_ERROR)
{
printf("%s: %d\n", apn_error_message(error), APN_ERR_CODE_WITHOUT_CLASS(apn_error_code(error)));
apn_error_free(&error);
return fail;
}
apn_set_mode(ctx, APN_MODE_SANDBOX, NULL);
apn_add_token(ctx, token, NULL);
}
The code work fine most of time.But sometimes, it does not, the application was blocked by apn_connect() accidentally, once a day recently.
Then I used the strace -p pid, just give a message blow:
read(39,
no more message.
And with the gdb attach the application process id, the message blow:
it looks like block at __read_nocancel().
So, after googling, I found the issues on stackoverflow:
http://stackoverflow.com/questions/11835203/openssl-ssl-connect-blocks-forever-how-to-set-timeout
and I view the libcapn source code, the __apn_connect() doesn't use the SSL_CTX_set_timeout() or SSL_SESSION_set_timeout(), of course it may have no effect just like that guy said.
Following, I will try to add SSL_CTX_set_timeout() or SSL_SESSION_set_timeout() to the __apn_connect() fuction and test it works or not.
I suggest give a fuction whic like apn_connect_timeout so that it can be setted the timeout.
THX.
The text was updated successfully, but these errors were encountered: