Javascript 在使用HTTPS时发送WebRTC服务器未运行的信号,获取许可被拒绝

Javascript 在使用HTTPS时发送WebRTC服务器未运行的信号,获取许可被拒绝,javascript,node.js,https,webrtc,Javascript,Node.js,Https,Webrtc,正在尝试使用https在本地主机上的simplewebrtc.com上部署代码 服务器代码与https的演示略有不同: /*global console*/ var fs = require('fs'); var options = { key: fs.readFileSync('./ssl_key/blarg.key'), cert: fs.readFileSync('./ssl_crt/blarg.cert') }; var yetify = require('yetif

正在尝试使用https在本地主机上的simplewebrtc.com上部署代码 服务器代码与https的演示略有不同:

/*global console*/
var fs = require('fs');

var options = {
    key: fs.readFileSync('./ssl_key/blarg.key'),
    cert: fs.readFileSync('./ssl_crt/blarg.cert')
};

var yetify = require('yetify'),
    config = require('getconfig'),
    uuid = require('node-uuid'),
    app = require('express'),
    https = require('https').createServer(options, app),
    io = require('socket.io').listen(https);

io.sockets.on('connection', function (client) {
    client.resources = {
        screen: false,
        video: true,
        audio: false
    };

    // pass a message to another id
    client.on('message', function (details) {
        var otherClient = io.sockets.sockets[details.to];
        if (!otherClient) return;
        details.from = client.id;
        otherClient.emit('message', details);
    });

    client.on('shareScreen', function () {
        client.resources.screen = true;
    });
.
.
.

});

https.listen(config.server.port);

if (config.uid) process.setuid(config.uid);
console.log(yetify.logo() + ' -- signal master is running at: http://localhost:' + config.server.port);
日志:

GEThttp://localhost:8888/socket.io/1/?t=1393090153747 net::ERR\u EMPTY\u响应

当我单击共享屏幕时,控制台将打印此内容
NavigatorUserMediaError{constraintName:,消息:,名称:“PermissionDeniedError”}

更新
使用
https://localhost:8888/socket.io/1/

它能在:8888/工作吗,如何工作?
我在上启用了屏幕共享标志chrome://flags
现在视频在一侧可见:)
另一方无法使用静态视频

更新2
使用
https://localhost:8888/socket.io/1/

另一方面,事情发生了变化,远程端的视频和屏幕共享都不起作用。

连接(
)http://localhost:8888/socket.io/1/?“
);连接到io.connect(“
https://localhost:8888/socket.io/1/?)
;在客户端

/global console中/


这样重写代码。它起作用了。

你是否尝试了
http
而不是
https
?http:信号服务器工作,屏幕共享不工作https:有了上述代码,信号服务器不工作,其他屏幕共享工作了是的,你是如何解决这个问题的?能让它在工作吗*仍然屏幕共享不起作用。当您使用https时,客户端中的“不允许http”意味着不安全的内容或url。实际上,在这两者之间发生了一些冲突:/Using
https://localhost:8888/socket.io/1/?
信令不工作远程流未添加:(屏幕共享和视频都不起作用,consoleOk中没有日志只需将本地主机更改为IP地址意味着本地主机为192.168.0.1:8888/socket
var fs = require('fs'),
    express = require('express'),
    https = require('https'),
    http = require('http');

var app = express();

app.use(express.static(__dirname));

app.use(function (req, res, next) {

    // Website you wish to allow to connect
    res.setHeader('Access-Control-Allow-Origin', 'https://172.17.20.67');

    // Request methods you wish to allow
    res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');

    // Request headers you wish to allow
    res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');

    // Set to true if you need the website to include cookies in the requests sent
    // to the API (e.g. in case you use sessions)
    res.setHeader('Access-Control-Allow-Credentials', true);

    // Pass to next layer of middleware
    next();
});


var privateKey = fs.readFileSync('./ssl_key/blarg.key'),
    certificate = fs.readFileSync('./ssl_crt/blarg.cert');
    //fs.readFileSync('fakekeys/privatekey.pem').toString(),
    //fs.readFileSync('fakekeys/certificate.pem').toString();

//http.createServer(app).listen(8001);

var yetify = require('yetify'),
    config = require('getconfig'),
    uuid = require('node-uuid'),
    io = require('socket.io').listen(https.createServer({key: privateKey, cert: certificate}, app).listen(8000));

function describeRoom(name) {
    var clients = io.sockets.clients(name);
    var result = {
        clients: {}
    };
    clients.forEach(function (client) {
        result.clients[client.id] = client.resources;
    });
    return result;
}

function safeCb(cb) {
    if (typeof cb === 'function') {
        return cb;
    } else {
        return function () {};
    }
}

io.sockets.on('connection', function (client) {
    client.resources = {
        screen: false,
        video: true,
        audio: false
    };

    // pass a message to another id
    client.on('message', function (details) {
        var otherClient = io.sockets.sockets[details.to];
        if (!otherClient) return;
        details.from = client.id;
        otherClient.emit('message', details);
    });

    client.on('shareScreen', function () {
        client.resources.screen = true;
    });

    client.on('unshareScreen', function (type) {
        client.resources.screen = false;
        if (client.room) removeFeed('screen');
    });

    client.on('join', join);

    function removeFeed(type) {
        io.sockets.in(client.room).emit('remove', {
            id: client.id,
            type: type
        });
    }

    function join(name, cb) {
        // sanity check
        if (typeof name !== 'string') return;
        // leave any existing rooms
        if (client.room) removeFeed();
        safeCb(cb)(null, describeRoom(name))
        client.join(name);
        client.room = name;
    }

    // we don't want to pass "leave" directly because the
    // event type string of "socket end" gets passed too.
    client.on('disconnect', function () {
        removeFeed();
    });
    client.on('leave', removeFeed);

    client.on('create', function (name, cb) {
        if (arguments.length == 2) {
            cb = (typeof cb == 'function') ? cb : function () {};
            name = name || uuid();
        } else {
            cb = name;
            name = uuid();
        }
        // check if exists
        if (io.sockets.clients(name).length) {
            safeCb(cb)('taken');
        } else {
            join(name);
            safeCb(cb)(null, name);
        }
    });
});

if (config.uid) process.setuid(config.uid);

console.log('running on https://localhost:8000 and http://localhost:8001')