Code Monkey home page Code Monkey logo

ais-udp's Introduction

AIS UDP

A demon service to dispatch a AIVDM/AIVDO Protocol data stream into MongoDB. Details about this project can be found here.

Installation

The installation is done by cloning the project and installing the dependencies.

git clone https://github.com/3epnm/ais-udp
cd ais-udp
npm install

Before the project can be started, the configuration must first be adjusted.

Configuration

The configuration is carried out with node-config-ts. A simple but effective configuration manager for typescript based projects. The easiest way to adapt the configuration is to adapt the file default.json from the config directory of the project folder. In practice, it has proven useful to use a new configuration file depending on the NODE_ENV variable. How this works is explained in the documentation of node-config-ts. Refer to the npm page node-config-ts to learn all features it offers.

The configuration file has the following content, which is explained below.

{
    "database": {
        "url": "mongodb://127.0.0.1:27017",
        "options": {
            "useNewUrlParser": true,
            "useUnifiedTopology": true
        },
        "dbName": "ais_tracker",
        "sender": "***"
    },
    "dispatcher": {
        "udpPort": 10110
    },
    "logger": {
        "level": "info",
        "filter": 0,
        "filename": ""
    },
    "ssh": {
        "enabled": false,
        "forward": "27017:127.0.0.1:27017",
        "host": "***"
    }
}

Database section

The configuration of the database is as follows:

Parameter Description
url The connection url to the MongoDB instance.
options

Options to setup the Database Connection.
All options of the native MongoDB Driver are possible.
dbName The name of the database where to store report data.
sender

The name of the sender. Makes it possible to distinguish between
those who have created or updated a report in the case of several transmitters.

AIS Tools initializes the database with the necessary collections and more important creates the necessary indexes. Default documents and position documents expire after one day and position documents are set with a geospatial index. Shipdata documents do not expire and will be updated if a new report is received.

Dispatcher section

The only configuration option is the the port number of the UDP stream with AIVDM/AIVDO Protocol Reports.

Logger section

Logging is done with Winston universal logging library.

Parameter Description
level

The logging levels are named after npm logging levels and allows
to configure how verbose the messages are written to a logfile or to stdout.
filter


The filter is a MMSI Number - an identifier every AIS Report has
and which is unique to the vessel.
Used to log the processing of Reports for a specific vessel.
filename

The filename where the log file is written to.
If empty, the messages are written to stdout.

The logger uses the winston-daily-rotate-file to archive log files if used in a debug level for a longer period of time. In addition, the logger can also be controlled via the NODE_ENV environment variable. If set to "debug", the log messages also written to stdout, regardless of whether the filename parameter is set or not.

SSH section

The following configuration enables an SSH tunnel to be created if required, which is started as a child process.

Parameter Description
enabled Whether the function is used or not
forward Which port from the source is forwarded to a port at the destination
host The host of the source

Start the Service

Once the configuration is done, the service can be started with npm start

ais-udp's People

Contributors

mbretschn avatar

Watchers

 avatar

Forkers

berbaba

ais-udp's Issues

throw new DispatcherError('Error', err) on NPM START

Hello, after running npm start I got the following error:

> ts-node index.ts

{ message: 'Start AISUDPService(2311678)',
  level: 'info',
  timestamp: '2021-08-16T07:36:11.558Z' }
{ message: 'Database connected',
  level: 'info',
  timestamp: '2021-08-16T07:36:11.614Z' }
{ message: 'UDPDispatcher starting',
  level: 'info',
  timestamp: '2021-08-16T07:36:11.615Z' }

/root/ais-udp/lib/UDPDispatcher.ts:88
        throw new DispatcherError('Error', err)
              ^
DispatcherError: Error
    at UDPDispatcher.onError (/root/ais-udp/lib/UDPDispatcher.ts:88:15)
    at Socket.emit (events.js:198:13)
    at Socket.EventEmitter.emit (domain.js:448:20)
    at state.handle.lookup (dgram.js:243:14)
    at process._tickCallback (internal/process/next_tick.js:63:19)```

Can you help me to resolve this issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.