Debugging topshelf as a service - topshelf

I am having problems running TopShelf as a service and I am not getting much info to help troubleshoot. I am using dotNet core 2.2.
I get this error when I start it:
Error: 1053: The service did not respond to the start or control
request in a timely fashion.
Event logs show:
A timeout was reached (30000 milliseconds) while waiting for the Test service to connect.
The Test service failed to start due to the following error: The service did not respond to the start or control request in
a timely fashion.
It message shows a 30 second timeout in the error popup happens in about 1 second. I don't think its a time out.
I my current setup I am using an IHostedService, but I have tried it without this. Here is the current setup.
var hostBuilder = SetupHost();
var rc = HostFactory.Run(x =>
{
x.Service<IHost>(s =>
{
s.ConstructUsing(name => hostBuilder.Build());
s.WhenStarted(tc =>
{
_logger = tc.Services.GetRequiredService<ILogger<Kickoff>>();
tc.StartAsync();
});
s.WhenStopped(tc => tc.StopAsync());
});
x.RunAsLocalService();
x.SetDescription("Test");
x.SetDisplayName("Test");
x.SetServiceName("Test");
x.EnableShutdown();
x.OnException(p => ExceptionOccured(p));
});
If you see something glaring people let me know.
My main goal is to find a technique to troubleshoot this. I've tried logging to a file with system.io but it does not produce results. I don't know how to debug it or get meaning information.

Related

Problem with connecting to websocket using TestCafe and Safari in BrowserStack

When running within a testcafe test in Safari using BrowserStack (command for run test: testcafe "browserstack:safari#15.3:OS X Monterey" src/ --skip-js-errors), upon loading an app that tries to connect to a websocket, I receive an error in the console of
"WebSocket connection to
'ws://localIP/FhPen2vWb!w!s*webAppAdress/https://websocketAdress'
failed: The request timed out".
I realized that when I run remote test in real safari - there wasn't this poblem. What can cause that? Is it bug? I can't find, if I can solve it..
enter image description here
Code example below. In this code after 'maximizeWindow()' the app tries to connect to websocket for getting data, but it isn't happened and the next code row don't do right thing and tests became failed.
import { Selector } from 'testcafe';
import { Role } from 'testcafe';
fixture('Create agent')
.page('https://${{webAppUrl}}')
.beforeEach(async t => {
await t.useRole(userRole);
});
test('Create agent for Ped Source', async t => {
await t
.click('span.icon.icon-add')
.typeText('input[name=\'modelName\']', 'testCafeModel')
.click('button[type=\'submit\']')
.maximizeWindow()
.click('div[title=\'Pedestrian Library\']')
});

OneSignal registration fails after refresh

I am using OneSignal in my Laravel/Vue app. I have included it within <head> as stated in documentation:
<script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async=""></script>
<script>
var OneSignal = window.OneSignal || [];
OneSignal.push(function() {
OneSignal.init({
appId: "{{ env('ONESIGNAL_APP_ID') }}"
});
OneSignal.showNativePrompt();
});
</script>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/OneSignalSDKWorker.js')
.then(function () {
console.log('Service worker registered');
})
.catch(function (error) {
console.log('Service worker registration failed:', error);
});
} else {
console.log('Service workers are not supported.');
}
</script>
I also have a service worker of my own, so I've followed the documentation here as well.
What is happening after a hard reset is that service worker gets installed and it is all fine, however once I refresh the page I am getting:
OneSignalPageSDKES6.js?v=151102:1 Uncaught (in promise) InvalidStateError: The current environment does not support this operation.
at Function.getServiceWorkerHref (https://cdn.onesignal.com/sdks/OneSignalPageSDKES6.js?v=151102:1:41510)
at xe. (https://cdn.onesignal.com/sdks/OneSignalPageSDKES6.js?v=151102:1:144028)
at Generator.next ()
at r (https://cdn.onesignal.com/sdks/OneSignalPageSDKES6.js?v=151102:1:716)
And I have no idea what does that mean? What is "current environment"? Where to start debugging? I've tried putting console logs around it, however it led me nowhere...
You would start debugging by looking at the source code of the library.
In your case your library is the OneSignal SDK for browsers.
Let's do this!!!
We can see that this error is thrown by getServiceWorkerHref function (which is defined here) and the error message is driven by the InvalidStateReason enumeration:
case InvalidStateReason.UnsupportedEnvironment:
super(`The current environment does not support this operation.`);
break;
If you look at the first linked file, you will see the note on getServiceWorkerHref OneSignal developers left for the those who dare venture into their source code:
else if (workerState === ServiceWorkerActiveState.Bypassed) {
/*
if the page is hard refreshed bypassing the cache, no service worker
will control the page.
It doesn't matter if we try to reinstall an existing worker; still no
service worker will control the page after installation.
*/
throw new InvalidStateError(InvalidStateReason.UnsupportedEnvironment);
}
As you can see, the error is raised when the service worker has the "Bypassed" state. What is that, you may ask? Let's look at ServiceWorkerActiveState enumeration below, in the same file:
/**
* A service worker is active but not controlling the page. This can occur if
* the page is hard-refreshed bypassing the cache, which also bypasses service
* workers.
*/
Bypassed = 'Bypassed',
It seems, when the browser "hard-refreshes" the page, it bypasses the service worker and OneSignal can't properly initialize when that happens. Hard-refresh can happen for a number of reasons — here are some of them (to the best of my knowledge):
if you click the refresh button a bunch of times (usually seconds consecutive refresh within a short period of time may trigger this)
if you have caching disabled in your DevTools
if the server sets a no-cache header
What is happening after a hard reset
I don't know exactly what you mean by "hard reset", but that sounds like it would trigger this issue. I would suggest you close your browser and then visit the page you are working on without using "reset" functions — theoretically, the service worker should be used for caching on consecutive visits and that would ensure OneSignal can function.

How to set Execution Timeout in Hotchocolate 10.4.3

we are using Hotchocolate 10.4.3 for my .net core service.
we are using code first approach.
All settings are in startup.cs exactly similar to their Star War example.
Hotchocolate web site says default timeout for request is 30 sec but I found my application throwing Transaction error after 1 min.
I want to increase that to 2 min.
Also why server still executes everything even after timeout exception.
I always see Transaction error at end after all my code gets execute properly.
If everything is going to run properly why to even then throw error?
I'm still learning graphql. Please correct me if anything sounds incorrect.
In HotChocolate v10, you can set the execution timeout when you add the service in your Startup's ConfigureServices() method:
services.AddGraphQL(
SchemaBuilder.New()
.AddQueryType<Query>()
.Create(),
new QueryExecutionOptions { ExecutionTimeout = TimeSpan.FromMinutes(2) });
They have a good repo of examples here: https://github.com/ChilliCream/hotchocolate-examples
Documentation on the execution options: https://chillicream.com/docs/hotchocolate/v10/execution-engine/execution-options
EDIT: In v11, the syntax has changed:
services
.AddGraphQLServer()
.AddQueryType<Query>()
.SetRequestOptions(_ => new HotChocolate.Execution.Options.RequestExecutorOptions { ExecutionTimeout = TimeSpan.FromMinutes(10) });

Actionscript 4: NetConnection.connect(...) does not fire a NetStatusEvent event

I downloaded the red5-recorder (http://www.red5-recorder.com/) , which fails to allow me to start recording. After debugging I found that the netconnection, needed to record to a media server, created does not fire a NetStatusEvent event, so essentially it fails silently. I have implemented the connection with the following minimal working example:
trace("make net connection");
nc = new NetConnection();
nc.client = { onBWDone: function():void{ trace("bandwidth check done.") } };
trace("add event listener");
nc.addEventListener(NetStatusEvent.NET_STATUS, function(event:NetStatusEvent) {
trace("handle");
});
trace("connect!");
nc.connect("rtmp://localshost/oflaDemo/test/");
trace("connect done");
The output of this piece of code is:
make net connection
add event listener
connect!
connect done
The actionscript api states that the connect-call always fires such an event:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetConnection.html#includeExamplesSummary
Moreover, the netconnection is not 'connected' (a state of the NetConnection object) 10 seconds after the call. I also took a look at this: NetConnect fails silently in Flash when called from SilverLight But the fix suggested by the author, swapping rtmp and http in the connection uri, do not work. Also, I tested the uri and in fact the exact same code sniplet in a personal project, where it did work. I just can not seem to find why connecting to a media server fails silently in the red5-recorder project.
The awkward part is that if I pass some random string as a conenction uri, still nothing happens (no event, no exception, no crash). Also not setting nc.client becore nc.connect(), which caused exceptions in my experience, did not cause exceptions.
Any suggestions are welcome.
You are setting the address to localshost instead localhost.
nc.connect("rtmp://localshost/oflaDemo/test/");
Correct address:
nc.connect("rtmp://localhost/oflaDemo/test/");

Windows service won't start when using other credentials from active directory

I have created a windows service. The OnStart method only exists of a Timer setup:
Timer startupTimer = new Timer();
protected override void OnStart(string[] args)
{
startupTimer.Elapsed += new ElapsedEventHandler(startupTimer_Elapsed);
startupTimer.Interval = 60000;
startupTimer.Enabled = true;
startupTimer.AutoReset = false;
}
When I install the service, and run it directly (log on as: 'Local System Account') it works perfectly, it starts within 2 seconds. But, the service needs to acces a network share with special permissions. Therefore I setup 'Log on as: [domain\user-account]'. When I then start the service, it takes more than 30 seconds and I receive the following error message: The service did not respond to the start or control request in a timely fasion.
Searching for this error gives a lot of solutions, but (as far as I googled) never related to different credentials. I doubt that setting the time-out value from 30 seconds to 60 seconds will help, because the OnStart code is very small. Also, it's a production server which I can't reboot just to try another TimeOut setting in the registry.
Does someone has any ideas/suggestions for me?
Many thanks in advance!

Resources