private void process() {

        if (node.ping(peerNode, 2000)) {
            log.info(peerNode + ": pong.");
        } else {
            log.warn(peerNode + ": pang!");
        }

        while (true) {
            try {
                OtpErlangObject msg = mbox.receive();
                log.debug("Incoming message: {}", msg.toString());
                Task task = new Task(msg, this, engine);
                if (task.getAction().equals("handshake")) {
                    replyWithOKResult(task.getFrom(), mbox.self());
                } else if (task.getAction().equals("stop")) {
                    log.info("Stop requested by peer. Exiting.");
                    replyWithOK(task.getFrom());
                    OtpEpmd.unPublishPort(node);
                    System.exit(0);
                } else {
                    exec.submit(task);
                }
            } catch (IllegalArgumentException e) {
                log.error("Invalid message format: " + e);
            } catch (OtpErlangDecodeException e) {
                log.error("Received message could not be decoded: " + e);
            } catch (OtpErlangExit e) {
                log.error("Remote pid " + e.pid() + " has terminated");
                System.exit(1);
            } catch (Exception e) {
                String trace = "";
                for (StackTraceElement st : e.getStackTrace()) {
                    trace += " -- " + st.toString();
                }
                log.error(e.toString() + trace);
                System.exit(1);
            }
        }
    }