Skip to content

Passing an unresolved hostname to connect causes thread to crash #6

@dpetran

Description

@dpetran

When trying to connect to a host that isn't resolvable via DNS causes the event-loop thread to crash.

(def host1 (ntcp/event-loop))
(def client (connect host1 {:host "unresolved.local" :port 8885}))

In the logs you'll find:

SEVERE: thread died
java.nio.channels.UnresolvedAddressException
	at java.base/sun.nio.ch.Net.checkAddress(Net.java:130)
	at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:673)
	at net.async.tcp$detect_connecting.invokeStatic(tcp.clj:174)
	at net.async.tcp$detect_connecting.invoke(tcp.clj:165)
	at net.async.tcp$event_loop_impl.invokeStatic(tcp.clj:199)
	at net.async.tcp$event_loop_impl.invoke(tcp.clj:195)
	at clojure.lang.AFn.applyToHelper(AFn.java:154)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$apply.invoke(core.clj:662)
	at net.async.tcp$in_thread$fn__13942.invoke(tcp.clj:30)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.base/java.lang.Thread.run(Thread.java:829)

The event loop still exists and the thread is still runnable, but the connection isn't retried and the only sign that something is wrong is the SEVERE line in the logs.

We discovered it when bringing up a service in an environment with dynamic DNS, where the server it was connecting to was not yet resolvable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions