• 当调用wcf, 小心返回值包含enum越界的错误。


    前段时间处理过一个调用wcf的exception(那是一个非常奇怪的exception, 经过line by line的调试,exception是在调用出wcf operation的时候抛的):

    System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:01:59.9730000'. ---> System.IO.IOException: The read operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:01:59.9730000'. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

     

    今天又遇到这个exception,而且都是在刚出wcf operation 调用的时候抛得,但郁闷的是我们竟然忘了上次是什么原因造成,怎么解决的了。

    今天只能由重新调查,第一感觉可能是server和client的接口定义不一致的,但通过调查,包括使用wcftestclient测试,发现感觉是错误的。

    但错误是怎么导致的?通过comment一些代码测试后,大家终于搞清楚了原因,最让我们感到脸红的是这个错误跟前段时间处理的exception完全是同一个问题导致的,竟然我们都忘记了原因。

    所以再此记录下来:

    这个原因:在返回client的结构中有一个enum的属性越界了,那是因为server代码没有检查enum是否越界,直接强制转换成enum. 当从server返回client一个越界的enum就产生了那个exception.

    汗。

  • 相关阅读:
    如何批量查看容器内部的进程?
    如何一键将k8s中configmap以及secret的配置变成本地环境变量
    如何快速批量下载m3u8(ts)视频?
    如何快速搜索?
    【待学习】知识点/小类
    【待学习】科目/大类
    总览:SpringCloud基础结构
    AES 加密解密
    JVM学习:方法重载的优先级
    反射操作数组---反序列化小知识
  • 原文地址:https://www.cnblogs.com/lxg226/p/1837048.html
Copyright © 2020-2023  润新知