-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Long Time operation Fail after 2 minutes #5228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I tried to change the node timeout but had no effect. Using this in Startup.cs resolves the problem: options.UseSocketHosting(); But I had to build it manually, since the last version isn't available in Nuget. Will this package be maintened? |
@spyker0 did you figure out any other way to fix this....Im also having same issue and im generating pdfs with puppeteer in node |
This is the only way I find it. |
What namespace is UseSocketHosting in? Is this part of JavaScriptServices or something else? EDIT: Found it, although using that just throws a method not found exception for me. This issue is being caused by the Node HTTP server closing the connection after 2 minutes (which it does by default) before the PDF generation operation has completed. This issue mentions making this configurable but was archived shortly after. Is it possible to configure this timeout currently using the NodeServices API or some kind of override in the JavaScript modules that get invoked? @SteveSandersonMS I assume this still isn't possible? Are you still accepting PRs for this? |
I wouldn't recommend using it. It's not something we've ever shipped as a supported package, nor are we planning to do so since we found that the default HTTP-based transport performs equally well.
Since you can call some function of your own inside Node that changes the server.timeout value, it doesn't seem like any other change is needed. So, I'll close this, but please let us know if you think I'm mistaken. |
@SteveSandersonMS sorry, perhaps I'm being naive but in order to set the timeout would it not have to be done in this file? I don't fully understand how the NodeServices APIs work but surely my custom JavaScript module just gets imported dynamically, by that point, it's too late to set server timeout? |
No, you can make the call from anywhere. Just do it before any other call that you want the new timeout to be effective on. |
@SteveSandersonMS still not following - surely this would mean I need to have access to the HTTP server object in my module, which I don't because the module isn't doing anything to do with handling HTTP requests. Do you have an example by any chance? |
All I'm saying is that, if you want to change Node's server.timeout, then you can go to whatever JS code you are invoking via NodeServices and add a line that modifies server.timeout as per Node docs. |
@SteveSandersonMS apologies to keep coming back to this, but I still don't think this is possible. Consider the following module called module.exports = function (callback, data) {
setTimeout(main(callback, data), 180000);
}
const main = (callback, data) => {
if (data) {
callback(null, data);
}
callback("No data!", null);
} Invoked by the following C#: this.nodeServices.InvokeAsync<string>("app", "random data string").Result; This will throw the following exception because the Node HTTP server being spun up internally by INodeServices is timing out after two minutes (as is the default): From what I can see, to prevent this happening you would need to set the server.timeout of the Node HTTP server created on line 118 of this file which is absolutely not possible from within the module defined above. I really am hoping I'm being stupid, as I need a solution to this, but I can't get my head around your comments about setting this myself in my module. Thanks in advance! |
OK, I finally understand your scenario. Thanks for the clarification! I now see that the underlying issue is that your code doesn't have access to the If this is something you're interested in adding a PR to address, I think we'd certainly be open to it. My suggestion would be:
Reopening since this is definitely a fair feature request! |
Yay, thanks! Sorry for my poor previous explanations. Just to let you know, there's a potential duplicate here that I raised: #8447 You may want to close one or the other and I can raise a PR referencing whichever issue remains open. Thanks. |
OK, your other issue is less noisy, so I'll close this one in favour of that. But I'll paste my PR suggestion to the other one. Thanks! |
Microsoft.AspNetCore.All Version 2.1.2
Microsoft.AspNetCore.NodeServices Version 2.1.1
Microsoft.NETCore.App Version 2.1.2
TargetFramework netcoreapp2.1
I'm doing something like this (generate a PDF file from HTML in node services, and them return the file to the user):
https://code.msdn.microsoft.com/How-to-export-HTML-to-PDF-c5afd0ce
I'm using the following plugin on node file:
https://github.com/westy92/html-pdf-chrome
No problem generating some small report's, but when the operation take longer than 2 minutes, the request fail and I got the following exception:
But the operation still's running and success is logged in the console.
Also if I configure it to generate a local File, the file is generated.
Startup.cs
pdf2.js
HomeController.cs
The text was updated successfully, but these errors were encountered: