Previous part is here.
Web service
Next step will be to run dotnet application in service that starts with your virtual PC and system will restart it if application crashes. We will create specific user (www.example.com) that will run dotnet application. Why do we need specific user? Answer is quite simple – security.
Let me elaborate on that. Nginx is running from specific user (
www-data). Service will run from another user that we will create (
www.example.com). Surely you can run everything from root account, but if nginx or dotnet has some vulnerability then hacker will get access to whole system. If each service has own quite limited account that not even able to login. Moreover,
[...Read More]
Previous part is here.
Configuring Web Server
I chose nginx as web server because after research it looks like it is gaining a lot of popularity while second contender Apache2 is losing popularity.
First step is to ensure that your web server is working correctly. Because http port is opened in Amazon router and in your virtual PC you should be able to access it from outside from your browser. Just type http://<you static IP address> in your browser and press Enter. You should see standard nginx web page.
Next step is to make sure that nginx will not serve anything that is not specifically added. Edit file /etc/nginx/sites-available/default and replace it content with following:
server {
listen 80 default_server;
listen [::]:80 default_server;
return 444;
}
[...Read More]
Some time ago I needed simple tutorial site. Initially I was thinking about static page hosting and I started research. But during research I found AWS Lightsail service. It cost $3.5 per month and offers 1 vCPU, 512 MB of RAM, 20 GB of SSD space and 1 TB of data transfer. It is about that the same as my current hosting offers but in case of Amazon it is your own virtual PC, and you can do whatever you like there. It looks attractive, but there is one catch. It is Linux. I had some experience with Linux, but it was far from extensive. On another side I really like challenges, so I decided to try it.
But before
[...Read More]
Recently I got relatively simple deadlock case, but I found quite interesting things during investigation. Our application hangs when user tries to quit it. I got dump file for this case and started investigation.
Call stack for main thread looks like this:
...
clr!JITutil_MonContention+0x115
System_ni!System.ComponentModel.Component.Dispose(Boolean)$##60031F8+0x40
System_ni!System.IO.FileSystemWatcher.Dispose(Boolean)$##600266D+0xd7
System_ni!System.IO.FileSystemWatcher.Dispose(Boolean)$##600266D+0xa6
System_ni!System.ComponentModel.Component.Dispose()$##60031F7+0x1a
...
As you clearly see, application waiting in
FileSystemWatcher’s
System.ComponentModel.Component.Dispose. If you go to
https://sourceof.net and paste name of the method there to see source code, you will see that there is
lock(this) and it looks like some other thread obtained lock before us. Obviously, I went over other 168 threads and found 2 similar call stacks. First thread was executing event from first
[...Read More]
Case of frozen File Explorer
Some time ago I started to get strange freezes when I try to open File Explorer. New File Explorer appears on screen, renders left and top part and then displays “Working on it…” where files supposed to be and then nothing. And today I would like to share my discoveries.
Obviously, first thing I tried to kill File Explorer and start over. Exactly the same behavior. I rarely use File Explorer because I prefer FAR file manager. But sometimes I do use File Explorer, mostly to copy files via Remote Desktop. In this particular case I decided to start FAR file manager to check something. And to my surprise, exactly the same happens to FAR.
[...Read More]
Recently one person asked me to check following code:
1. if (s.Length > 1)
2. {
3. string numberString = s.Substring(0, 1);
4. result.Text = s.Substring(pos + 1, s.Length - pos);
5. }
When that person runs this code, it throws ArgumentOutOfRangeException exception on line #3. But as you can see, first line checks that string is not empty and s.Substring(0, 1) should never throw any exception. And looks like that person was correct.
Then I found that this code compiled for .NET Core 3.1. I tried to increase version to .NET 5 and problem is still there. I put breakpoint to line 3 and run application. When application stopped on that line, I
[...Read More]
Recently I got strange situation in our application. We have two different classes in .NET that exposed to managed code via COM interfaces. Both classes look very similar but one class by some reason supports IDispatch while another class does not. We have piece of code that work quite differently depending on IDispatch support. And was asked to investigate what is going on and why these two classes behave different.
Here is some data. First class looks like this:
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public class Foo : BaseClass1, IDisposable
Second class looks like this:
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public class Bar : BaseClass2, IMyInterface
IMyInterface declared like this:
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("XXX")]
If
[...Read More]
I am happy owner of iPhone from iPhone 4. I never had any issue with them. All issues were some kind of my fault. But one thing is really annoying me modern iPhones – charge cables. I do not remember what year it started, but at one moment I did realize that plastic that protect lightning cable started to crack. I did not pay attention and thought that I misused it. So, I just used tape to isolate that place. But then it cracked in different place and in another place. I went I bought another cable. And year later perfectly working cable started to crack again. Cable was still working fine, just looks ugly and all wires are stripped.
[...Read More]
Probably everyone who wants to follow recent trends in hardware is usually watching some news over that subject and views some reviews for new hardware. For most hardware reviews I usually watching Hardware Unboxed channel. While many other youtubers provide the same content, but I really like their style, they way of presenting, data they provided etc. Plus following them for quite some time I never seen any leaning towards any side. They are always on the truth side.
And today I seen this video:
Nvidia Bans Hardware Unboxed, Then Backpedals: Our Thoughts - YouTube. Basically, if you do not have time to watch, NVIDIA sent email to Hardware Unboxed saying that do not pay enough attention (and do
[...Read More]