我正在尝试使用socket.io将从树莓派(python 2.7.9)发送的值发送到我的nodeJS服务器。
我的目标是通过websocket连接连续地发送多个值,传递给我的本地node服务器,它应该将这些值显示在index.html上(用于其他客户端,例如只有树莓派发送值的Web-Chat)。
我的目标是通过websocket连接连续地发送多个值,传递给我的本地node服务器,它应该将这些值显示在index.html上(用于其他客户端,例如只有树莓派发送值的Web-Chat)。
I tried everything but I can't make a handshake and send data. When I open the "http://IP_ADDRESS:8080" in my browser I see a connection but not with my python Code.
Please I need some help....
server.js
var express = require('express')
, app = express()
, server = require('http').createServer(app)
, io = require('socket.io').listen(server)
, conf = require('./config.json');
// Webserver
server.listen(conf.port);
app.configure(function(){
app.use(express.static(__dirname + '/public'));
});
app.get('/', function (req, res) {
res.sendfile(__dirname + '/public/index.html');
});
// Websocket
io.sockets.on('connection', function (socket) {
//Here I want get the data
io.sockets.on('rasp_param', function (data){
console.log(data);
});
});
});
// Server Details
console.log('Ther server runs on http://127.0.0.1:' + conf.port + '/');
my python websocket-code in which I just want send values
#!/usr/bin/env python
#
from websocket import create_connection
ws = create_connection("ws://IP_ADDRESS:8080/")
ws.send("Some value")
ws.close();
http://IP_ADDRESS:8080
中的IP_ADDRESS
是 127.0.0.1 还是与树莓派连接到同一网络的地址? - Will