Monday, September 23, 2019

Windows 10 Complaining Permission Denied for Bind, but Ports Unused

An application on Windows 10 cannot open a TCP port, and the error message is something like

Error:  Permission denied - bind(2) for 127.0.0.1:7334

However, when you attempts to see if any uses the port, you finds nothing, such as,

netstat -abo | find ":7334"

In fact, this error can be the result of the "exclude port range". For instance, we can query the excluded port range on the system using,

netsh interface ipv4 show excludedportrange protocol=tcp
The output can be something like,

Protocol tcp Port Exclusion Ranges

Start Port    End Port
----------    --------
      7248        7347
      7348        7447

* - Administered port exclusions.

From the output we can see that the 7334 tcp port is in the exclusion range, and thus we can not assign it to a process.

Gradle Complaining about JDK not Found

I was attempting to compile a Kotlin project, and encountered the following error:


* What went wrong:

Execution failed for task ':compileKotlin'.

> Kotlin could not find the required JDK tools in the Java installation 'C:\Program Files\Java\jre1.8.0_211' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
The answer to the problem is straightforward is to inform Gradle where the JDK is. Since I am on a Windows host, and the host has had these installed:

C:\>dir "C:\Program Files\Java\"
....

05/14/2019  09:58 AM    <DIR>          .
05/14/2019  09:58 AM    <DIR>          ..
03/04/2019  09:39 PM    <DIR>          jdk-11.0.2
03/04/2019  09:29 PM    <DIR>          jdk1.8.0_201
05/12/2019  08:32 PM    <DIR>          jre1.8.0_211
.....

C:\>

I added the following line to the gradle.properties file, and the problem went away,

org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_201

Thursday, September 19, 2019

Updating Plex Media Server to Latest FreeNAS Plugin on Command Line in Jail

There are two methods to upgrade Plex Media Server in FreeNAS Jail. 
  1. Method 1. Upgrading Plex Media Server to Latest FreeBSD Release. Using this method, you don't have to wait for FreeNAS developers to upgrade Plex Media Server in the plugin repository.
  2. Method 2. Upgrading Plex Media Server to Latest FreeNAS Plugin. 
This post is about Method 2, and documents the steps to upgrade Plex Media Server on Command Line.

  1. Login or open FreeNAS shell
  2. List jails
    
    $ jls
    

    The output looks like the following
    
    $ jls
       JID  IP Address  Hostname     Path
         1              plex         /mnt/Storage/iocage/jails/plex/root
    $
     
  3. Open a shell inside the jail. The command is as follows,
    
    jexec ${JID} csh
    

    In the above, the jail ID (JID) is 1. Since we can only the csh as root, we open a shell inside the jail as follows
    
    $ sudo jexec 1 csh
    
  4. Upgrading the plexmediaserver package. Inside the jail, we do
    
    # pkg upgrade plexmediaserver
    

    If the installed version is already latest, we should observe something similar to the following,
    
    root@plex:/ # pkg upgrade plexmediaserver
    Updating iocage-plugins repository catalogue...
    iocage-plugins repository is up to date.
    All repositories are up to date.
    Checking integrity... done (0 conflicting)
    Your packages are up to date.
    root@plex:/ #
    

    However, if there is a newer version, the upgrade will commerce.

  5. Restart Plex Media Server if it gets upgraded as follows inside the jail,
    
    # service plexmediaserver restart
    


Monday, September 16, 2019

Locate a Command on Windows

We know we can locate a command on Unix-like operating systems like Linux or OS X using the which command, such as,

$ which ls
/bin/ls
$
Can we do the similar on Windows? Yes, we use the where, e.g.,

C:\>where find
C:\Windows\System32\find.exe

C:\>

Saturday, September 14, 2019

Disqus Complaining "Content Security Policy" Error on Jekyll Webite

I was building a website using Jekyll with the Minima theme. Following the instruction of the Minima theme, I set up Disqus to posts on the site by adding the "Disqus shortname" to Jekyll site configuration file _config.yml, such as,


disqus:
    shortname: mysite-short-name

However, the site displays an error message,

We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
When I clicked on the error message, Disqus shows an error message

Content Security Policy error
It turns out that to make Disqus work, we must include a url attribute in the configuration file, i.e., after I added the attribute, the configuration now includes,

url: https://mysite-url-used-for-disqus
disqus:
    shortname: mysite-short-name

Tuesday, August 27, 2019

Jekyll Complains "GitHub Metadata: No GitHub API authentication could be found."

When building a Jekyll site, I encountered the following error message,


$ bundle exec jekyll build
Configuration file: _config.yml
            Source: foosite/
       Destination: _site
 Incremental build: disabled. Enable with --incremental
      Generating...
   GitHub Metadata: No GitHub API authentication could be found. 
   Some fields may be missing or have incorrect data.


The sources of this error are many. What caused the error in my case? It is actually the combination of the two facts:

  1. I used the Jekyll SEO Tags plugin, and
  2. I did not include a description value in the _config.yml file. 

After my adding a description map to the _config.yml file, the problem went away, e.g.,

$ cat _config.yml
...
description: this is my awesome site. 
...

Tuesday, August 20, 2019

Dealing with Data Degradation or Bit Rots

If you have set up a NAS or alike, such as a FreeNAS system, you know that the system periodically "scrubs" the disks. The disk scrubs are to to wipe clean the disks, instead, they are to prevent bit rots, a slow degradation of data store on storage devices, e.g., a magnetic disk's gradual loosing its magnetic charge.

If you don't have a NAS that does it for you, how do you reduce the chance of loosing the data due to bit rots (or data degradation), in particular, you have lots of important data on external hard drives? There are a number of tools that can help us if you don't wish to take the task into your own hand to program one. This post bookmarks three such tools,

  1. CSHATAG
  2. ExactFile
  3. DiskFresh 
A combination of application number 3 and one of applications number 1 and 2 in the above can give us a piece of mind, i.e., to detect bit rots and to prevent bit rots.