fc websocket的例子,试了好几次都不行,测试连接不上。【提问11】在线编辑的示范代码。

fc websocket的例子,试了好几次都不行,测试连接不上。【提问11】在线编辑的示范代码。

Error: Unexpected server response: 400 Handshake Details Request URL: http://wsdo-wserv-bdbuzvetem.cn-hangzhou.fcapp.run/ Request Method: GET Status Code: 400 Bad Request Request Headers Sec-WebSocket-Version: 13 Sec-WebSocket-Key: NRoIDYBBiUljSefROabmkQ== Connection: Upgrade Upgrade: websocket Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits Host: wsdo-wserv-bdbuzvetem.cn-hangzhou.fcapp.run Response Headers Access-Control-Expose-Headers: Date,x-fc-request-id,x-fc-error-type,x-fc-code-checksum,x-fc-invocation-duration,x-fc-max-memory-usage,x-fc-log-result,x-fc-invocation-code-version Content-Type: application/json; charset=utf-8 X-Fc-Code-Checksum: 14489168969317334862 X-Fc-Error-Type: FCCommonError X-Fc-Instance-Id: c-63e252f4-210cc1e3701d4f179d58 X-Fc-Invocation-Service-Version: LATEST X-Fc-Request-Id: 1e9871e1-2301-4376-926e-aa68e1237dd0 Date: Tue, 07 Feb 2023 13:35:27 GMT Content-Length: 118

用postmain访问时得到的信息

{"errorMessage":"Handler 'handler' is missing on module 'index'","errorType":"FunctionUnhandledError: HandlerNotFound","stackTrace":["HandlerNotFound: Handler 'handler' is missing on module 'index'"]}

我记得ws是先要走http请求来握个手对吧。 现在好像就那个环节出错了。但现在是否代码就只响应ws,并没有http的handler,我跟这下面链接的步骤做的 https://help.aliyun.com/document_detail/424823.html

展开
收起
云上静思 2023-02-08 18:03:46 1129 分享 版权
2 条回答
写回答
取消 提交回答
  • 我记得是需要在函数计算中添加一个HTTP触发器,就能够正确处理websocket请求。

    您可以参考以下文档,了解如何在函数计算中添加HTTP触发器:https://help.aliyun.com/document_detail/424823.html。

    此外,还需要确保您的代码中有一个HTTP处理程序,这样子才能够正确处理websocket请求。

    2023-02-08 19:26:24
    赞同 1 展开评论
  • ws 只支持 custom runtime 或者 custom container 哈,检查下您的 runtime 是否正确。

    此答案来自钉钉群“阿里函数计算官网客户"

    2023-02-08 18:23:20
    赞同 1 展开评论

快速交付实现商业价值。

收录在圈子:
+ 订阅
阿里云 云原生应用平台 肩负阿里巴巴集团基础设施云化以及核心技术互联网化的重要职责,致力于打造稳定、标准、先进的云原生产品,成为云原生时代的引领者,推动行业全面想云原生的技术升级,成为阿里云新增长引擎。商业化产品包括容器、云原生中间件、函数计算等。
还有其他疑问?
咨询AI助理