lambdaisland / lambdaisland/trikl

Crash when connecting

Open
#2 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
156
Forks
8
PR merge metrics
No merged PRs in 30d

Description

I'm trying to follow along the example. I start a socket repl, and eval the following lines:

(require '[trikl.core :as t])

;; store clients so we can poke at them from the REPL
(def clients (atom []))

;; Start the server on port 1357, as an accept handler just store the client in
;; the atom.
(def stop-server (t/start-server #(swap! clients conj %) 1357))

Then when connecting using telnet localhost 1357 I get the following exception in the repl window:

Exception in server loop #error {
 :cause class java.net.Socket$SocketOutputStream cannot be cast to class java.io.FileOutputStream (java.net.Socket$SocketOutputStream and java.io.FileOutputStream are in module java.base of loader 'bootstrap')
 :via
 [{:type java.lang.ClassCastException
   :message class java.net.Socket$SocketOutputStream cannot be cast to class java.io.FileOutputStream (java.net.Socket$SocketOutputStream and java.io.FileOutputStream are in module java.base of loader 'bootstrap')
   :at [trikl.telnet$send_telnet_command invokeStatic telnet.clj 31]}]
 :trace
 [[trikl.telnet$send_telnet_command invokeStatic telnet.clj 31]
  [trikl.telnet$send_telnet_command doInvoke telnet.clj 31]
  [clojure.lang.RestFn invoke RestFn.java 2442]
  [trikl.telnet$prep_telnet invokeStatic telnet.clj 39]
  [trikl.telnet$prep_telnet invoke telnet.clj 38]
  [trikl.core$start_client invokeStatic core.clj 526]
  [trikl.core$start_client invoke core.clj 524]
  [trikl.core$make_client invokeStatic core.clj 557]
  [trikl.core$make_client doInvoke core.clj 547]
  [clojure.lang.RestFn invoke RestFn.java 442]
  [trikl.core$start_server$fn__599 invoke core.clj 625]
  [clojure.core$binding_conveyor_fn$fn__5754 invoke core.clj 2030]
  [clojure.lang.AFn call AFn.java 18]
  [java.util.concurrent.FutureTask run FutureTask.java 264]
  [java.util.concurrent.ThreadPoolExecutor runWorker ThreadPoolExecutor.java 1128]
  [java.util.concurrent.ThreadPoolExecutor$Worker run ThreadPoolExecutor.java 628]
  [java.lang.Thread run Thread.java 830]]}

I'm on MacOS. Have tried connecting using eshell and shell in emacs, and zsh terminal.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with trikl/telnet.clj at send_telnet_command, line 31, then follow the prep_telnet and start_client calls shown in the stack trace. Reproduce the example with start-server and telnet localhost 1357; done means a client connection no longer crashes the server loop on macOS shells.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
cli, networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.