SMGP程序 与电信网关连接 是不是的会出现连接断开,因为我们有个重连机制,可能需要过10分钟,或者时间更长1天或者更长时间才能连接上网关,请高手赐教!!!
但是SMGP程序是采用长连接的,如果信道上(连接)没有数据,获发送链路包(心跳包)来维持连接,
我自己下了个模拟器测试一直都不会出现这种问题,但是在真是环境下电信网关那 就会出现这种问题,但是网关能支持几百个客户端的连接,网速缓慢因素也不可能(我们传输的数据并不是很大,对于电信网关来说足以)
我自己现在采用了两种模式:多进程时候 我开启多个SMGP程序去连接电信网关 这时只开启一对收发线程 也没问题的,(我自己在模拟环境下测试OK的。)
当采用多线程连接时候 采用并发 也没问题, 我这个程序有个隔3秒就重连,但是程序一直重连失败 不知道啥问题,想请教各位? 我自己认为是网关关闭了连接,但是我每次在调用socket后都会关闭的啊 郁闷死了,!!!而且每次recv时候我都会设置超时操作!!
请看错误代码:[20111125001557] smgp_socket_select_recv() recv error=[104][Connection reset by peer], iRet = [-1]!
smgp_select_recv():recv failed!Len=-1
Recvthread:1 SmgpRecvMsg() Error Head recvlen [-1][12]
[20111125001557]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
[20111125001557]Recvthread:1 SmgpRecvMsg() thread ReConnectSMG() fail!
[20111125001909]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
[20111125001909]Recvthread:1 SmgpRecvMsg() thread ReConnectSMG() fail!
[20111125002221]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
[20111125002221]Recvthread:1 SmgpRecvMsg() thread ReConnectSMG() fail!
[20111125002533]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
[20111125002533]Recvthread:1 SmgpRecvMsg() thread ReConnectSMG() fail!
[20111125002845]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
[20111125002845]Recvthread:1 SmgpRecvMsg() thread ReConnectSMG() fail!
[20111125003157]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
[20111125003157]Recvthread:1 SmgpRecvMsg() thread ReConnectSMG() fail!
[20111125003203]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
[20111125003203]Recvthread:1 SmgpRecvMsg() thread ReConnectSMG() fail!
[20111125003515]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
[20111125003515]Recvthread:1 SmgpRecvMsg() thread ReConnectSMG() fail!
[20111125003603]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
[20111125003603]Recvthread:1 SmgpRecvMsg() thread ReConnectSMG() fail!
[20111125003606]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
[20111125003606]Recvthread:1 SmgpRecvMsg() thread ReConnectSMG() fail!
[20111125003918]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
[20111125003918]Recvthread:1 SmgpRecvMsg() thread ReConnectSMG() fail!
[20111125003921]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
[20111125003921]Recvthread:1 SmgpRecvMsg() thread ReConnectSMG() fail!
[20111125003924]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
[20111125003924]Recvthread:1 SmgpRecvMsg() thread ReConnectSMG() fail!
[20111125003927]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
[20111125003927]Recvthread:1 SmgpRecvMsg() thread ReConnectSMG() fail!
[20111125003930]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
[20111125003930]Recvthread:1 SmgpRecvMsg() thread ReConnectSMG() fail!
[20111125003936]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
[20111125003936]Recvthread:1 SmgpRecvMsg() thread ReConnectSMG() fail!
[20111125004000]Recvthread:1 SmgpRecvMsg() thread smgp_socket_close()!
ConnectSMG():connect socket failed!
------解决方案--------------------------------------------------------
sleep(3)不是三秒,而且,smgp是采用的socket通信,不想cmpp协议采用的心跳来维持长连接,smgp是短连接,所有你建的重练机制完全可以在socket连接失败出现异常时在连接,不需要sleep来做,还有最好在两个socket直接使用单线程!