【问题标题】:Unable to connect to deepstream无法连接到深流
【发布时间】:2017-02-18 18:36:55
【问题描述】:
【问题讨论】:
标签:
javascript
connect
deepstream.io
【解决方案1】:
要解决此问题,您需要将 index.html(或您命名的包含 deepstream 客户端连接的文件)托管到网络服务器。
当您连接到网络服务器以访问 index.html 时,它将执行 javascript 以启动 deepstream 客户端,然后建立与运行在即默认端口 6020 上的 deepstream 服务器的连接
希望这会有所帮助。
【解决方案2】:
Hi Im also a new user. Have you installed all the needed packages?
For me it works and my Index.html looks like this:
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/deepstream.io-client-js/2.1.1/deepstream.js"></script>
</head>
<body>
<div id="app"></div>
<input type="text" />
<script type="text/javascript">
var client = deepstream('localhost:6020').login();
var record = client.record.getRecord('myname');
var input = document.querySelector('input');
console.log("helloooo");
record.set('firstname', input.value);
});
record.subscribe('firstname', function(value) {
input.value = value;
});
</script>
</body>
</html>
【解决方案3】:
deepstream 是一个 websocket 服务器 - 它需要使用 deepstream 客户端访问(参见上面的答案)。将 URL 键入浏览器(或使用其他 HTTP 通信方式请求它)不会执行任何操作。