WebSocket问题:此WebSocket实例已经有一个未完成的"SendAsync"调用 [英] WebSocket Issue: There is already one outstanding 'SendAsync' call for this WebSocket instance

查看:1689
本文介绍了WebSocket问题:此WebSocket实例已经有一个未完成的"SendAsync"调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用System.Net.WebSockets.WebSocket.SendAsync(..)方法.

I using System.Net.WebSockets.WebSocket.SendAsync(..) method.

我反复面对这个问题.

我了解从这些帖子中,我们一次最多只能执行一个sendAsync操作:

I understand that from these posts we can do at most one sendAsync operation at a time:

http://stackoverflow.com/questions/23151605/websockets-sendasync-exception

http://stackoverflow.com/questions/23151605/websockets-sendasync-exception

https://social.msdn.microsoft.com/forums/en-us/a2f0e273-fbca-4bf2-8937-084238247843/how-to-use-socketreceivefromasync-and-wait

https://social.msdn.microsoft.com/forums/en-us/a2f0e273-fbca-4bf2-8937-084238247843/how-to-use-socketreceivefromasync-and-await

如何解决此问题?这个问题已经解决了吗?还是正在进行中?

How to solve this issue? Is this already fixed or some work is going on?

推荐答案

您好,JP.M.P,

Hello JP.M.P,

我建议看看这两个使用System.Net.WebSockets的示例项目.客户端一次仅发出一个发送(非阻塞异步).我的猜测是,这是为什么您收到错误消息的关键.  您可以扩展 这样可以向客户端添加一个队列,该队列将在每次响应后将消息发送到服务器.

I suggest taking a look at these two sample projects that use System.Net.WebSockets.  The client is only issuing one send at a time (non-blocking async).  My guess is this is the key to why you are getting the error message.  You could extend this to add a queue to the client that will fire the messages the the server after each response.

异步服务器套接字示例

异步客户端套接字示例


这篇关于WebSocket问题:此WebSocket实例已经有一个未完成的"SendAsync"调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆