某些帐户的实时通知需要很长时间

时间:2019-04-01 05:39:38

标签: javascript getstream-io

我正在尝试调试为什么使用实时api花费很长时间才能到达实时通知。进行手动数据提取按预期工作。

我已经注册了一个个人getstream帐户并使用了这些密钥,通知延迟符合预期。

video of getstream realtime notification working as expected

但是,使用完全相同的代码并用我们现有的应用程序简单地切换键,就需要花费超过16分钟的时间(!!!)(我不会在此处附加视频,因为它很大,但是通知到达时间的屏幕截图。

screenshot of getstream realtime notification taking more than 16mins before the notification is received

我可以通过查看网站上的流资源管理器选项卡并启用自动刷新来确认数据已提交到getstream。

这是我编写的示例poc代码,用于说明问题https://github.com/parasquid/getstream_poc/blob/master/views/index.html.erb

<script src="https://cdn.jsdelivr.net/npm/getstream/dist/js_min/getstream.js"></script>
hello!

<div id="timer"></div>
<p><button id="add-activity">Add activity</button>

<script>
  var interval
  var client = stream.connect('<%= @apikey %>', null,  '<%= @appid %>');

  var userFeed = client.feed('user', '<%= @user_id %>', '<%= @user_token %>')
  var userSubscription = userFeed.subscribe(
    () => userFeed.get()
      .then(streamData => console.log(streamData))
      .then(() => clearInterval(interval)),
    (errors) => console.error({errors})
  );

  var notificationFeed = client.feed('notification', '<%= @user_id %>', '<%= @notification_token %>')
  var notificationSubscription = notificationFeed.subscribe(
    () => notificationFeed.get().then(streamData => console.log(streamData)),
    (errors) => console.error({errors})
  );

  button = document.querySelector("button#add-activity")
  button.onclick = (e) => {
    timer = document.querySelector("div#timer");
    var seconds = 0
    interval = setInterval(() => {
      seconds++;
      timer.innerHTML = seconds;
    }, 1000);

    fetch("/add_activity")
      .then(r => r.json())
      .then(json => console.log(json));
  }

</script>

据我所知,这似乎是特定于帐户而不是实施;也许我只是在做一些奇怪的事情。感谢指针!


更新2019-04-02

我创建了另一个应用程序,该应用程序与我在另一个帐户上的设置能够尽可能地镜像(只是更改位置,因为看起来我们需要联系支持来更改现有应用程序的位置,因此我们仅使用用户和通知供稿组),虽然肯定会有更多的延迟,但它不如原始应用那么糟糕。

screenshot with app located in singapore

screenshot of old slow app and new fast app side by side

0 个答案:

没有答案