2014-02-19 59 views
0

我正在用C开发一个简单的ejabberd客户端,使用libstrophe。它连接并开始处理消息,因为它应该这样做。Strophe不可恢复的TLS错误

但是,经过一段时间(ejabberd服务器的两三次ping后),我的连接关闭并且状态设置为DISCONNECTED。下面是调试线的尾部:

xmpp DEBUG Unrecoverable TLS error, 5. 
xmpp DEBUG Closing socket. 
DEBUG: disconnected event DEBUG Stopping event loop. 
event DEBUG Event 
oop completed. 

我初始化并连接如下。

xmpp_initialize(); 

/* read connection params */ 
if(set_xmpp_conn_params(&conn_params) < 0) { 
    fprintf(stderr, "Could not retrieve connection params from %s\n", 
        SERVER_CONF_FILE); 
    return -1; 
} 

/* initialize the XMPP logger */ 
xmpp_log = xmpp_get_default_logger(XMPP_LOG_LEVEL); 
xmpp_ctx = xmpp_ctx_new(NULL, xmpp_log); 

/* create a connection */ 
xmpp_conn = xmpp_conn_new(xmpp_ctx); 

/* login */ 
xmpp_conn_set_jid(xmpp_conn, conn_params.jid); 
xmpp_conn_set_pass(xmpp_conn, conn_params.password); 

/* create a client */ 
xmpp_connect_client( xmpp_conn, conn_params.host, 0, 
         agent_conn_handler, xmpp_ctx); 

/* enter the event loop */ 
xmpp_run(xmpp_ctx); 

/* the code below is executed 
    whenever connection handler @agent_conn_handler exits */ 

/* release the connection and context */ 
xmpp_conn_release(xmpp_conn); 
xmpp_ctx_free(xmpp_ctx); 

为什么我得到那个TLS错误信息?

谢谢。

+0

你对TLS使用openssl,gnutls或schannel吗? –

+0

是的,我正在使用'openssl'。 –

回答

0

错误5是SSL_ERROR_SYSCALL。 OpenSSL的docs说:

Some I/O error occurred. The OpenSSL error queue may contain more information on the error. If the error queue is empty (i.e. ERR_get_error() returns 0), ret can be used to find out more about the error: If ret == 0, an EOF was observed that violates the protocol. If ret == -1, the underlying BIO reported an I/O error (for socket I/O on Unix systems, consult errno for details).

在实践中,这可能意味着服务器下跌的出于某种原因连接。我建议使用WireShark做一个包跟踪以获取更多信息。例如,当客户端提供TLS版本1.1时,我们发现使用RSA库的服务器发生了这种情况。

+0

当我查看Wireshark时,在断开连接之前,客户端首先发送一个'[FIN,ACK]'数据包,然后从服务器接收RST。你是如何解决你的案子的? –

+0

服务器在客户端发送FIN/ACK之前是否发送FIN?另外,将流解码为SSL,并查看最新的SSL消息是什么。在我们看到的情况下,我们必须强制客户端使用TLS 1.0,直到我们替换了服务器上的RSA库。 –

+0

嗨,我是使用libstrophe创建一个应用程序作为XMPP客户端,你会碰巧有关于“不可恢复的TLS错误,6”的经验。 ? –