简体   繁体   中英

ERR_CONNECTION_RESET error when calling Edge.func in C# async method through POST service

I have also raised an issue in the github pages for Edge, linked here https://github.com/tjanczuk/edge/issues/579

I am trying to utilize Edge in my .NET application to run a quick node program to do some minor video processing.

I have verified that the javascript works - tested it independently running 'node test.js'. And I have verified that I am calling and using the Edge.func method properly by creating a small C# console app and testing to see if, when I run it in CMD (testApp.exe), the video processing works through node using Edge (it does).

The problem is that when I try to run the async method shown below through my POST web service using Edge I get the first log - 'In Edge Task' - but I never get the log at the bottom - 'in async call' - and client side I get a network error saying failed net::ERR_CONNECTION_RESET.

public static async Task Start()
{
    LogManager.Instance.WriteLog("In Edge Task");
    var func = Edge.Func(@"
        var ffmpeg = require('fluent-ffmpeg');
        return function (data, callback) {
            var proc2 = ffmpeg('testFile-0.webm')
                .input('testFile-1.webm')
                .on('error', function(err) {
                    callback(null, 'ERRORRRR');
                })
                .on('end', function() {
                    callback(null, '');
                })
                .mergeToFile('merged-fromNET.mp4', 'tempDir');
        }
    ");
    LogManager.Instance.WriteLog("in async call");
    await func(null);
}

This async task Start() method works properly if I call it from my test console app...

I have verified my post service is set up correctly because without executing this method using Start.Wait(), commenting it out, the service executes properly. I have installed the necessary node modules and the used video files and necessary dlls in the proper directories so I am sure that is not the issue.

Please help, thank you for your time.

So I figured out the answer to my question with the help of this question - Starting a process with credentials from a Windows Service

It seems that a web service is executed with "Network Service" permissions and upon checking windows event viewer I was getting an access violation - meaning I needed to execute this chunk of code as a user with proper permissions. So I followed the logic provided in the question I linked to in order to create a process that would execute a simple exe I set up to execute the chunk of code I posted. I had to be careful to give my user proper permissions to access the folder with the exe and that was pretty much it.

With this technique, it seems easy to set up a web service that executes node.js logic with Edge https://github.com/tjanczuk/edge - Thanks tjanczuk

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM