轮询冻结,Pebble.js,ajax,node.js

Polling freezes, Pebble.js, ajax, node.js

本文关键字:js ajax node Pebble 冻结      更新时间:2023-09-26

我是Pebble的新手。最近,我为 pebble 客户端编写了一个简单的程序,通过轮询从服务器获取数据。我使用 Pebble.js、ajax 和 setInterval 函数。服务器位于节点.js上。我遇到的问题是轮询在 20+ 查询后冻结,鹅卵石上没有变化,但仍然可以在服务器上获得查询信号。

这里的客户端代码,服务器端的代码是一个简单的 http 响应。

var UI = require('ui');

var card = new UI.Card({
title: 'Pebble.js',
body: 'Press any button.'
});
card.show();
var ajax = require('ajax');
setInterval(function(){ 
ajax({ url: 'http://182.92.151.205:20000/quote', type: 'json' },
function(data) {
card.body(data.quote);
card.title(data.author);
},
function(error){
card.body(error);
card.title('no');
}
);
}, 5000);

我解决了自己,原因:使用 ajax 时没有 gc!