由于 MQTT 错误,AWS App Sync 订阅不起作用

编程入门 行业动态 更新时间:2024-10-26 08:31:37
本文介绍了由于 MQTT 错误,AWS App Sync 订阅不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在我的 React 应用上调用这个 graphql 订阅:

I am calling this graphql subscription on my react app:

export const OnCreateMessage = `
  subscription OnCreateMessage($conversationId: ID!) {
    onCreateMessage(messageConversationId: $conversationId) {
      id
      content
      authorId
      messageConversationId
      createdAt
    }
  }
`

这就是我在类组件中调用它的方式:

This is how I call it inside a class component:

API.graphql(
    graphqlOperation(subscriptions.OnCreateMessage, {conversationId: "c074c7b7-f6db-459a-a1d8-cd290aee33ea"})
  ).subscribe({
    next: ({ provider, value }) => console.log({provider, value}),
    error: error => console.warn("did not get messages")
});

但是,当我运行我的应用程序并调用它时,我的网络选项卡上出现此错误:

However, when I run my app and this is called, I get this error on my network tab:

{
  "errors" : [ {
    "errorType" : "BadRequestException",
    "message" : "Subscriptions over MQTT is not supported."
  } ]
}

我在 AWS 文档中看到MQTT over WebSockets 将不再可用于新的 AppSync API".但我现在不知道该怎么办.

I saw on the AWS docs that "MQTT over WebSockets will no longer be available for new AppSync APIs" but I don't know what to do now.

有人可以调查一下并帮助我吗?

Can someone look into this and help me out?

推荐答案

我不确定你是否找到了答案,但我们在一个项目中面临同样的问题,它要求你使用 GraphQL 客户端可以通过纯 WebSockets 处理订阅.请参阅关于使用 AWS AppSync 客户端的这个问题的答案.

I'm not sure if you found an answer to this, but we are facing the same thing with a project and it requires that you use a GraphQL client that can handle subscriptions over pure WebSockets. See the answer to this question about using the AWS AppSync client.

这篇关于由于 MQTT 错误,AWS App Sync 订阅不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-23 04:16:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1034890.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不起作用   错误   MQTT   AWS   Sync

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!