rabbibotton / clog

CLOG - The Common Lisp Omnificent GUI
Other
1.48k stars 101 forks source link

Connection errors: browser can't communicate with server. #246

Closed MonadMania closed 1 year ago

MonadMania commented 1 year ago

I'm on Windows 10 using SBCL, and I've tried this on two separate machines. My browsers are Firefox and Chrome.

Page changes and form submissions trigger the following error:

[2022-11-19 20:27:16 [ERROR]] Error while processing connection: The condition Couldn't write to #<SB-SYS:FD-STREAM for "socket 127.0.0.1:8080, peer: 127.0.0.1:51426" {1007C6AC73}>: The specified network name is no longer available. occurred with errno: 0.

This makes communication between the browser and LISP impossible. Print and format statements don't work at all in event handlers. Most tutorial examples work, but the mutlipart data upload example doesn't work - nothing prints to the REPL.

This specific error came from tutorial 17, but it's the same error every time. https://github.com/rabbibotton/clog/blob/main/tutorial/17-tutorial.lisp

Can someone please help me find the cause of this error? I'd like to make the tutorials work.

rabbibotton commented 1 year ago

Does it occur with even tutorial 1?

Can you run the builder (ql:quickload :clog/tools) (clog-tools:clog-builder)

That error is actually btw being generated by the http layer which means is a network error. So, check you windows 10 firewall.

MonadMania commented 1 year ago

@rabbibotton thank you for checking in. Yes, it even happens in Tutorial 1. I can run the builder, but I don't know how to use it yet. Browser-side changes occur, but communication with the REPL doesn't work.

Do you know what changes to make to the Windows firewall? I've tried enabling inbound connections to SBCL, but this hasn't worked.

MonadMania commented 1 year ago

By the way, the CLOG builder can create new projects and similar things. I made a test project which showed up in my local file system.

rabbibotton commented 1 year ago

That is even more strange, as the builder is a clog app itself. Are you running a 32bit windows or 64bits? I know that sbcl historically has some issues on win32.

MonadMania commented 1 year ago

I'm running 64-bit Windows on both machines, and my Emacs and SBCL are both 64-bit.

MonadMania commented 1 year ago

In tutorial 1, I added a print statement to the on-click handler. On my machines, nothing prints to the REPL which launched the page. Similarly, in tutorial 17, a text file uploaded to the app should be printed in the REPL, but it's not.

(defun on-new-window (body) "On-new-window handler." (let ((hello-element (create-child body "<h1>Hello World! (click me!)</h1>"))) (set-on-click hello-element (lambda (obj) (declare (ignorable obj)) (setf (color hello-element) :green) (print "Operation succeeded."))))) ; Will this print to the REPL?

rabbibotton commented 1 year ago

Can you send me a screenshot of your repl startup?

You are seeing the Hello World on the browser though correct?

On Mon, Nov 21, 2022 at 1:54 PM Casey Coleman @.***> wrote:

In tutorial 1, I added a print statement to the on-click handler. On my machines, nothing prints to the REPL which launched the page. Similarly, in tutorial 17, a text file uploaded to the app should be printed in the REPL, but it's not.

(defun on-new-window (body) "On-new-window handler." (let ((hello-element (create-child body "

Hello World! (click me!)

"))) (set-on-click hello-element (lambda (obj) (declare (ignorable obj)) (setf (color hello-element) :green) (print "Operation succeeded."))))) ; Will this print to the REPL?

— Reply to this email directly, view it on GitHub https://github.com/rabbibotton/clog/issues/246#issuecomment-1322507826, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYUEFKFQSWAGQOWZYO3GELWJPAN7ANCNFSM6AAAAAASFUX3MI . You are receiving this because you were mentioned.Message ID: @.***>

MonadMania commented 1 year ago

The REPL gives an error, but the page loads successfully. image The URL and icon load correctly. image "Hello World!" Shows up. image

The on-click handler executes. image

However, the print statement disappears into the ether. Changing to a format statement, in various iterations, didn't seem to help. image

MonadMania commented 1 year ago

I looked into error code 1, and from what I see, it's a "wrong function call" (not that I know what that means in this case).

MonadMania commented 1 year ago

Here's what happens when I close the browser: the new error message shows up above the current REPL prompt and below the NIL that open-browser returned. image

rabbibotton commented 1 year ago

Ok. Now I think understand. The first error (exited with error). Is because trivial-open-browser is not working on your machine. Someone else reported to me before that on windows 10 that is the case. That means you have to manually open the URL as it not popping the browser open, or is opening the browser but still returning it failed. You can safely ignore that.

The second error - that is from the socket layer. It is not an actual error or issue but the Lisp socket layer reports as such and can be ignored, sadly I have not found how to suppress the error condition. It just means the network has disconnected. A long running clog program would only see that on disconnect of the browser either by server or user. So also can be ignore.

Regarding the printing not showing up. Every handler runs in its own thread, which is not the thread your REPL is running on. However slime usually still picks it up. What version of slime are you using? also try (format #.standard-output "Hello from thread!") let me know if that worked.

MonadMania commented 1 year ago

The following successfully printed to the REPL from the on-click handler. (format #.standard-output "Hello from thread!")

I'm using SLIME version 2.24, which came bundled with Portacle. It turns out that I was receiving the print statements, but they were being channeled into the inferior-lisp buffer instead of the REPL - silly me.

I appreciate your time and effort. Thank you. By the way, using this information, I was able to upload the file in Tutorial 17.

rabbibotton commented 1 year ago

Consider upgrading - https://github.com/rabbibotton/clog/blob/main/WINDOWS.md

rabbibotton commented 1 year ago

BTW one reason to upgrade is that the print statements etc will work with newer slimes etc