You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses,
TemplateHaskell, OverloadedStrings #-}
importControl.ConcurrentimportqualifiedText.Blaze.Html5asHimportqualifiedData.TextasTimportData.Text (Text)
importControl.MonadimportYesodimportYesod.WebSocketsdataPiggies=PiggiesinstanceYesodPiggies
mkYesod "Piggies" [parseRoutes|
/ HomeR GET
|]
getHomeR::HandlerHtml
getHomeR =do webSockets (forever (do liftIO (threadDelay (1000*1000))
sendTextData ("Bump!"::Text)))
pure (H.script "// Create WebSocket connection.\n\ \const socket = new WebSocket('ws://localhost:3035');\n\ \\n\ \// Connection opened\n\ \socket.addEventListener('open', function (event) {\n\ \ socket.send('Hello Server!');\n\ \});\n\ \\n\ \// Listen for messages\n\ \socket.addEventListener('message', function (event) {\n\ \ console.log('Message from server ', event.data); socket.close()\n\ \});")
main = warpDebug 3035Piggies
I see this output
$ stack runhaskell wrp.hs --resolver lts-18.0
wrp.hs:30:8: warning: [-Wdeprecations]
In the use of ‘warpDebug’
(imported from Yesod, but defined in Yesod.Core.Dispatch):
Deprecated: "Please use warp instead"
|
30 | main = warpDebug 3035 Piggies
| ^^^^^^^^^
18/Jun/2021:17:38:23 +0100 [Info#yesod-core] Application launched @(yesod-core-1.6.20.1-Jp7zmLxTY8gEM32OuxAOUR:Yesod.Core.Dispatch src/Yesod/Core/Dispatch.hs:175:11)
C-c C-c
$ stack runhaskell wrp.hs --resolver lts-18.0
wrp.hs:30:8: warning: [-Wdeprecations]
In the use of ‘warpDebug’
(imported from Yesod, but defined in Yesod.Core.Dispatch):
Deprecated: "Please use warp instead"
|
30 | main = warpDebug 3035 Piggies
| ^^^^^^^^^
18/Jun/2021:17:35:13 +0100 [Info#yesod-core] Application launched @(yesod-core-1.6.20.1-Jp7zmLxTY8gEM32OuxAOUR:Yesod.Core.Dispatch src/Yesod/Core/Dispatch.hs:175:11)
127.0.0.1 - - [18/Jun/2021:17:35:17 +0100] "GET / HTTP/1.1" 200 362 "" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
127.0.0.1 - - [18/Jun/2021:17:35:17 +0100] "GET / HTTP/1.1" 500 - "" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
C-c C-cwrp.hs: Thread killed by timeout manager
ghc: Thread killed by timeout manager
The two "Thread killed by timeout manager" messages appear when I hit C-c C-c. But I've elsewhere seen the message appear without shutting down the server. This is the best repro I can make so far.
Is this expected behavior? It seems to be one message for the websocket thread and one for the handler. If I omit the webSockets call, there is only one.
The text was updated successfully, but these errors were encountered:
With this file
I see this output
The two "Thread killed by timeout manager" messages appear when I hit C-c C-c. But I've elsewhere seen the message appear without shutting down the server. This is the best repro I can make so far.
Is this expected behavior? It seems to be one message for the websocket thread and one for the handler. If I omit the
webSockets
call, there is only one.The text was updated successfully, but these errors were encountered: