Andy Lai
Andy Lai

Reputation: 1894

Cannot run Azure Durable Function locally via Visual Studio Code

I followed the tutorial Visual Studio Code quickstart and created a durable function locally. I got an error message when my durable function executed await client.startNew inside the starter function

const instanceId = await client.startNew(req.params.functionName, undefined, req.body);

Here is the error messages:

Executed 'Functions.HttpTrigger' (Failed, Id=84dc103d-bef9-4450-b4c6-9e612c6dc263) System.Private.CoreLib: Exception while executing function: Functions.HttpTrigger. System.Private.CoreLib: Result: Failure Exception: Error: write EPROTO 101057795:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:827: Stack: Error: write EPROTO 101057795:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:827: at _errnoException (util.js:992:11) at WriteWrap.afterWrite [as oncomplete] (net.js:864:14).

My environment:

Here is my code just copied from the tutorial.

const df = require("durable-functions");
module.exports = async function (context, req) {
        const client = df.getClient(context);
        const instanceId = await client.startNew(req.params.functionName, undefined, req.body);

        context.log(`Started orchestration with ID = '${instanceId}'.`);

        return client.createCheckStatusResponse(context.bindingData.req, instanceId);
    };

{
  "bindings": [
    {
      "authLevel": "anonymous",
      "name": "req",
      "type": "httpTrigger",
      "direction": "in",
      "route": "orchestrators/{functionName}",
      "methods": ["post"]
    },
    {
      "name": "$return",
      "type": "http",
      "direction": "out"
    },
    {
      "name": "starter",
      "type": "orchestrationClient",
      "direction": "in"
    }
  ]
}

How do I resolve this problem?

Upvotes: 1

Views: 1076

Answers (2)

Jerry Liu
Jerry Liu

Reputation: 17800

Update

The problem has been fixed since npm package durable-functions v1.1.3


You have met a known issue.

This is due to current IWebHookProvider implementation, which causes the DurableOrchestrationClient class to use the wrong webhook URLs. The workaround is to set local environment variable WEBSITE_HOSTNAME to localhost:, ex. localhost:7071

If VS Code has been opened before env setting, don't forget to restart it to bring new env variable into effect.

Upvotes: 3

Andy Lai
Andy Lai

Reputation: 1894

Just summarized what I did in case someone struggles with the same problem.

In Windows 10

  1. type the instruction in the terminal to set the environment variable

    setx WEBSITE_HOSTNAME "localhost:7071"

  2. Close vs code and restart it

Upvotes: 2

Related Questions