免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5054 | 回复: 6
打印 上一主题 下一主题

SMGP程序 与电信网关连接 经常会出现连接断开,可能10分钟能重连,可能需要1天才能连 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-28 15:33 |只看该作者 |倒序浏览
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!


论坛徽章:
0
2 [报告]
发表于 2011-12-28 16:01 |只看该作者
设置一下struct linger
l_onoff 非零
l_linger = 0;强制退出模式



论坛徽章:
0
3 [报告]
发表于 2011-12-28 16:21 |只看该作者
回复 2# hokuhouhi

我们的出发点是让程序能和网关连接上, 现在就是死循环一样 刚开始接收错误 然后就一直关闭 重连,一直关闭重连 !!!
   

论坛徽章:
0
4 [报告]
发表于 2011-12-28 16:58 |只看该作者
Connection reset by peer
这个……………………

电信网关可以ping吗?如果连不上,用ping试过吗?

论坛徽章:
0
5 [报告]
发表于 2011-12-28 17:10 |只看该作者
Error Message:
Connection reset by peer.

Explanation:

A connection was forcibly closed by a peer. This normally results from a loss of the connection on the remote socket due to a timeout or a restart. On a datastream socket, the connection was reset. This reset could be generated locally by the network system when it detects a connection failure, or it might be received from the remote host (in TCP terms, the remote host sent an RST packet). This error is also possible on a datagram socket; for instance, this error could result if your application sends a UDP datagram to a host, which rejects it by responding with an ICMP Port Unreachable.

User Action:

Check the following: 1. Ping the remote host you were connected to. If it doesn't respond, it might be offline or there might be a network problem along the way. If it does respond, this problem might have been a transient one (so you can reconnect now), or the server application you were connected to might have terminated (so you might not be able to connect again). 2. Ping a local host to verify that your local network is still functioning (if on a serial connection, see next step). 3. Ping your local router address. If you are on a serial connection, your local router is the IP address of the host you initially logged on to using SLIP or PPP. 4. Ping a host on the same subnet as the host you were connected to (if you know of one). This will verify that the destination network is functioning. 5. Type tracert at the command prompt to determine the path to the host you were connected to. This won't reveal too much unless you know the router addresses at the remote end, but it might help to identify if the problem is somewhere along the way.

以上来自微软。

RST 包是极不寻常的。相当于对方不管当前状态,强制截断链接——正常关闭是有一套协议的,便于双方清理资源。

你先试一下ping 和 traceroute , 如果这两个没问题,可能是电信实现的问题;如果这两个在你的客户端能通信时可用,连不上时也挂掉…………恭喜你,你撞墙了。

论坛徽章:
0
6 [报告]
发表于 2011-12-29 14:43 |只看该作者
回复 4# 狗蛋


    网关可以接收上百个连接  这个ping肯定是没问题的。

论坛徽章:
0
7 [报告]
发表于 2011-12-29 14:45 |只看该作者
回复 5# 狗蛋


    我也觉得是电信网关那边的问题,还想多听听高手的意见
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP