Stream Read/Write Timeout causes Invalid Operation Exception

前端 未结 2 1014
Happy的楠姐
Happy的楠姐 2021-01-15 05:21

I am trying to get a request from an API using:

RestClient client = new RestClient(\"https://gds.eligibleapi.com/v1.5/coverage/all?api_key=\"
    + apiSecr         


        
2条回答
  •  佛祖请我去吃肉
    2021-01-15 05:56

    As you can see in your screenshot, the CanTimeout property is false. So these properties are supposed to throw an exception; from the msdn page of Stream:

    Notes to Inheritors:

    The ReadTimeout property should be overridden to provide the appropriate behavior for the stream. If the stream does not support timing out, this property should raise an InvalidOperationException

    Keep in mind that you're looking at the debugger looking at the stream - the exception won't be thrown in your application until you actually touch the timeout properties.

提交回复
热议问题