Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 正在运行Azure功能不工作的信号器服务_Javascript_Signalr_Azure Functions_Signalr Hub_Signalr 2 - Fatal编程技术网

Javascript 正在运行Azure功能不工作的信号器服务

Javascript 正在运行Azure功能不工作的信号器服务,javascript,signalr,azure-functions,signalr-hub,signalr-2,Javascript,Signalr,Azure Functions,Signalr Hub,Signalr 2,我正在尝试使用azure函数和NodeJ运行SignalR服务,以便能够发送消息进行响应 实际上,我只想在本地设置后端服务(信号器+发送消息功能) 为此,我创建了信号器功能: module.exports = async function (context, req, connectionInfo) { console.log(connectionInfo) context.res.body = connectionInfo; }; 在function.json中 {

我正在尝试使用azure函数和NodeJ运行SignalR服务,以便能够发送消息进行响应

实际上,我只想在本地设置后端服务(信号器+发送消息功能)

为此,我创建了信号器功能:

module.exports = async function (context, req, connectionInfo) {
    console.log(connectionInfo)
    context.res.body = connectionInfo;
};
function.json中

{
    "bindings": [
    {
        "authLevel": "anonymous",
        "type": "httpTrigger",
        "direction": "in",
        "name": "request",
        "methods": [
        "get",
        "post"
        ]
    },
    {
        "type": "http",
        "direction": "out",
        "name": "res"
    },
    {
        "type": "signalR",
        "name": "signalRMessages",
        "connectionStringSetting": "Endpoint=https://xxxx.service.signalr.net;AccessKey=XXXXXXx;Version=1.0;",
        "hubName": "XXXXX",
        "direction": "out"
    }
    ]
}
{
    "bindings": [
    {
        "authLevel": "anonymous",
        "type": "httpTrigger",
        "direction": "in",
        "name": "req",
        "methods": [
        "get",
        "post"
        ]
    },
    {
        "type": "http",
        "direction": "out",
        "name": "res"
    },
    {
        "type": "signalRConnectionInfo",
        "name": "connectionInfo",
        "hubName": "xxxxxx", <== here I putted the SignalR service name without the domaine
        "direction": "in",
        "connectionStringSetting": "Endpoint=https://XXXXX.service.signalr.net;AccessKey=XXXXXX;Version=1.0;"
    }
    ]
}
{
    "IsEncrypted": false,
    "Values": {
    "AzureWebJobsStorage": "",
    "FUNCTIONS_WORKER_RUNTIME": "node",
    "AzureSignalRConnectionString": "Endpoint=https://xxxxxx.service.signalr.net;AccessKey=xxxxxxxxx;Version=1.0;"
    },
    "Host": {
    "LocalHttpPort": 7072,
    "CORS": "*"
    }
}
然后在我的第二个功能中,它将向信号机服务发送消息:

module.exports = async function (context, req) {
    context.log('JavaScript HTTP trigger function processed a request.');

    const name = (req.query.name || (req.body && req.body.name));
    const responseMessage = name
        ? "Hello, " + name + ". This HTTP triggered function executed successfully."
        : "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.";

    const updates = [{
        target: 'updated',
        arguments: [responseMessage]
    }];
    context.bindings.signalRMessages = updates;
    context.done();


}
function.json中

{
    "bindings": [
    {
        "authLevel": "anonymous",
        "type": "httpTrigger",
        "direction": "in",
        "name": "request",
        "methods": [
        "get",
        "post"
        ]
    },
    {
        "type": "http",
        "direction": "out",
        "name": "res"
    },
    {
        "type": "signalR",
        "name": "signalRMessages",
        "connectionStringSetting": "Endpoint=https://xxxx.service.signalr.net;AccessKey=XXXXXXx;Version=1.0;",
        "hubName": "XXXXX",
        "direction": "out"
    }
    ]
}
{
    "bindings": [
    {
        "authLevel": "anonymous",
        "type": "httpTrigger",
        "direction": "in",
        "name": "req",
        "methods": [
        "get",
        "post"
        ]
    },
    {
        "type": "http",
        "direction": "out",
        "name": "res"
    },
    {
        "type": "signalRConnectionInfo",
        "name": "connectionInfo",
        "hubName": "xxxxxx", <== here I putted the SignalR service name without the domaine
        "direction": "in",
        "connectionStringSetting": "Endpoint=https://XXXXX.service.signalr.net;AccessKey=XXXXXX;Version=1.0;"
    }
    ]
}
{
    "IsEncrypted": false,
    "Values": {
    "AzureWebJobsStorage": "",
    "FUNCTIONS_WORKER_RUNTIME": "node",
    "AzureSignalRConnectionString": "Endpoint=https://xxxxxx.service.signalr.net;AccessKey=xxxxxxxxx;Version=1.0;"
    },
    "Host": {
    "LocalHttpPort": 7072,
    "CORS": "*"
    }
}
我还在信号机服务设置中将
服务模式
设置为
无服务器

现在,我正试图通过在浏览器中运行
sendmessages
函数来测试这一点,该函数将触发
signal
函数

但是当我在浏览器上运行
sendMessages
函数时,
signar Serice函数
不会被触发,context.bindings只包含
req
(在
function.json
中列出了no
res
sendMessages


我的配置中是否遗漏了一些内容?

我也遇到了很多麻烦。。但就我所见,您的functions.json与示例有很多不同之处。与govertiate.json中的属性类型、名称和方向类似。请调整这些,然后再试一次。我也遇到了很多麻烦。。但就我所见,您的functions.json与示例有很多不同之处。与govertiate.json中的属性类型、名称和方向类似。请调整这些,然后重试。