1 设置代理超时时间ice_timeout

ICE的每个连接都有两个超时时间:ice_timeout、ice_connectiontimeout,分别对应消息的超时时间和连接建立

   的超时时间,可以通过在代理上调用上述方法来设置超时,也可以通过属性Ice.Override.Timeout、Ice.Override.ConnectTimeout

   来强制改变超时时间。

示例如下,

MyAdapter.Endpoints=tcp
–p 9999 –t 5000

base = __ice_runtime.stringToProxy(settings.CONF_DATA_CENTER_SERVERS).ice_timeout(500) //获得代理的超时时间

在客户端,我们使用对象代理进行远程调用,就如它们就在本地一样。但有时,网络问题还是要考虑的,于是Ice的对象代理提供了几个包装方法,以支持一些网络特性:

ice_timeout方法,声明为:Ice::ObjectPrx
ice_timeout(int) const;返回一个超时代理,当在指定的时间(单位毫秒)内没有得到服务器端响应时,操作终止并抛出Ice::TimeoutException异常。

示例代码

  1. Filesystem::FilePrx myFile = ...;
  2. FileSystem::FilePrx timeoutFile
  3. = FileSystem::FilePrx::uncheckedCast(
  4. myFile->ice_timeout(5000));
  5. try {
  6. Lines text = timeoutFile->read(); // Read with timeout
  7. } catch(const Ice::TimeoutException &) {
  8. cerr << "invocation timed out" << endl;
  9. }
  10. Lines text = myFile->read(); // Read without timeout

1设置定位服务缓存超时时间

Ice.Default.LocatorCacheTimeout

对于定位服务,可以缓存 代理对应的端点地址,这样可以减少定位请求。

Description

Specifies the default locator cache timeout
for indirect proxies. If num is set to a value larger than zero, locator cache entries older than num seconds are ignored. If set to 0, the locator cache is not used. If set to -1, locator cache entries
do not expire.

Once a cache entry has expired, the Ice run time performs a new locate request to refresh the cache before sending the next invocation; therefore, the invocation is delayed until the run time has refreshed the entry. If you set Ice.BackgroundLocatorCacheUpdates to
a non-zero value, the lookup to refresh the cache is still performed but happens in the background; this avoids the delay for the first invocation that follows expiry of a cache entry.

Ice.BackgroundLocatorCacheUpdates

2  报异常IceUtil::NullHandleException:

Null Smart Pointers

A null smart pointer contains a null C++ pointer to its underlying instance. This means that if you attempt to dereference a null smart pointer, you get an IceUtil::NullHandleException:

C++
TimeOfDayPtr tod;               // Construct null handle

try {
    tod->minute = 0;            // Dereference null handle
    assert(false);              // Cannot get here
} catch (const IceUtil::NullHandleException&) {
    ; // OK, expected
} catch (...) {
    assert(false);              // Must get NullHandleException
}

Default constructor

You can default-construct a proxy handle. The default constructor creates a proxy that points nowhere (that is, points at no object at all). If you invoke an operation on such a null proxy, you get an IceUtil::NullHandleException:

C++
try {
    SimplePrx s;        // Default-constructed proxy
    s->op();            // Call via nil proxy
    assert(0);          // Can't get here
} catch (const IceUtil::NullHandleException&) {
    cout << "As expected, got a NullHandleException" << endl;
}


ice使用过程遇到的问题的更多相关文章

  1. 试用mysql的infobright引擎

               海量数据分析处理,向来比较头疼费劲,特别是项目资金不允许的情况下,都是优先考虑开源软件,2007使用mysql,2009年尝试greenplum(公司最终选用oracle),20 ...

  2. iOS下WebRTC音视频通话(一)

    在iOS下做IM功能时,难免都会涉及到音频通话和视频通话.QQ中的QQ电话和视频通话效果就非常好,但是如果你没有非常深厚的技术,也没有那么大的团队,很难做到QQ那么快速和稳定的通话效果. 但是利用We ...

  3. 转:WebRTC技术及应用2 – NAT穿越技术的使用

    评:webrtc自带的打洞,穿透协议. 转: http://www.unclekevin.org/?p=924 959 views WebRTC技术及应用2 – NAT穿越技术的使用 发表回复 (题图 ...

  4. android灭屏后调用binder通讯竟然影响了socket的POLL_OUT事件,怪事。

    当你的android在灭屏(休眠)时分派(dispatch) Ice调用过程中,如果创建了新的进程,你的响应将不会预期那样工作,尽管你已经调用 ice_response或 ice_exception, ...

  5. 网络协议之:基于UDP的高速数据传输协议UDT

    目录 简介 UDT协议 UDT的缺点 总结 简介 简单就是美.在网络协议的世界中,TCP和UDP是建立在IP协议基础上的两个非常通用的协议.我们现在经常使用的HTTP协议就是建立在TCP协议的基础上的 ...

  6. c++ primer plus 第6版 部分二 5- 8章

    ---恢复内容开始--- c++ primer plus 第6版 部分二    5-  章 第五章 计算机除了存储外 还可以对数据进行分析.合并.重组.抽取.修改.推断.合成.以及其他操作 1.for ...

  7. (转)NAT与NAT穿越学习总结--ICE过程讲的不错

    转:http://cgs1999.iteye.com/blog/1994072 1.引言网络地址转换(Network Address Translation,简称NAT)是一种在IP分组通过路由器或防 ...

  8. ice grid 完整部署过程

    待补充 一 理论准备 一个IceGrid集群有一个registry(注册表,用于定位)和多个node组成. IceGrid配置包括集群配置和应用配置: config.grid是集群配置,配置Regis ...

  9. webrtc进阶-信令篇-之三:信令、stun、turn、ice

    webRTC支持点对点通讯,但是webRTC仍然需要服务端:  . 协调通讯过程中客户端之间需要交换元数据,    如一个客户端找到另一个客户端以及通知另一个客户端开始通讯.  . 需要处理NAT(网 ...

随机推荐

  1. ftp服务器端的安装及配置

    搭建过程 安装 vsftp 服务(yum 安装即可) 配置/etc/vsftpd/vsftpd.conf   anonymous_enable=NO #禁止匿名登录 local_enable=YES ...

  2. liunx下试用yum进行php及opchache扩展安装

    Centos 6.6 环境: php 5.6.29 nginx:1.10.2 1.配置安装包源 # CentOs 6.x rpm -Uvh http://mirror.webtatic.com/yum ...

  3. bootstrip 折叠菜单

    body { font-family: "宋体"; font-size: 12px } .menu { height: 30px; background: #e6e6e6; mar ...

  4. 第八十六节,html5+css3pc端固定布局,网站结构,CSS选择器,完成导航

    html5+css3pc端固定布局,网站结构,CSS选择器,完成导航 页面采用1280的最低宽度设计,去掉滚动条为1263像素. 项目是PC端的固定布局,会采用像素(px)单位. 网站结构语义 在没有 ...

  5. PAT 团体程序设计天梯赛-练习集 L1-019. 谁先倒

    给出甲.乙两人的酒量(最多能喝多少杯不倒)和划拳记录,请你判断两个人谁先倒. 输入格式: 输入第一行先后给出甲.乙两人的酒量(不超过100的非负整数),以空格分隔.下一行给出一个正整数N(<=1 ...

  6. Tomcat 配置支持APR

    对ARP支持,需要安装以下库: APR library JNI wrappers for APR used by Tomcat (libtcnative) OpenSSL libraries 其中JN ...

  7. [转]最常见的20个jQuery面试问题及答案

    毫无疑问,jQuery给了JavaScript急需的提振,这是一门如此有用,但同时总是常常被低估的语言. 在 jQuery 粉墨登场之前,我们曾经会写出冗长的JavaScript代码,不仅仅为更大型的 ...

  8. createThread和_beginthreadex区别

    摘自:http://blog.csdn.net/morewindows/article/details/7421759 CreateThread()函数是Windows提供的API接口,在C/C++语 ...

  9. [ An Ac a Day ^_^ ] FZU 2030 括号问题 搜索

    FZU一直交不上去 先写在这吧 #include<stdio.h> #include<iostream> #include<algorithm> #include& ...

  10. Chapter 15_2 编写模块的基本方法

    在Lua中创建一个模块最简单的方法是:创建一个table. 并将所有需要导出的函数放入其中,最后返回这个table. 下例中的inv声明为程序块的局部变量,就是将其定义成一个私有的名称: local ...