Server Sent Events vs. Websockets

TIL that server-sent events exist! This is thanks to an awesome video "Don't Use Websockets (Until you Try This...)" from Code with Ryan. Many thanks to Ryan for making this and the YouTube algorithm for showing it to me.

I'm excited to experiment and answer my question: will SSE work where Websockets are blocked? (my guess is yes). Hopefully, I'll update this when I find out.

Random google results that might help include:

  1. Building a Chat application with Angular and Spring Reactive SSE by Hantsy includes a demo project on github
    1. When I forked it, and tried it out in a github codespace I was NOT able to get things working:
      1. docker compose up -d # terminal 1
      2. cd server && sdk install kotlin && chmod +x gradlew && ./gradlew build -x test && java -jar build/libs/*.jar # terminal 2
      3. cd client && npm install && npm run start # terminal 3
        1. My guess is that a different version of node might be needed.

The error was:

Compiling @angular/router/testing : es2015 as esm2015
10% building 3/3 modules 0 active(node:10344) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
10% building 3/4 modules 1 active ...er/client/index.js?http://0.0.0.0:0/sockjs-node&sockPath=/sockjs-nodenode:internal/crypto/hash:71
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:140:10)
    at module.exports (/workspaces/angular-spring-sse-sample/client/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/workspaces/angular-spring-sse-sample/client/node_modules/webpack/lib/NormalModule.js:417:16)
    at /workspaces/angular-spring-sse-sample/client/node_modules/webpack/lib/NormalModule.js:452:10
    at /workspaces/angular-spring-sse-sample/client/node_modules/webpack/lib/NormalModule.js:323:13
    at /workspaces/angular-spring-sse-sample/client/node_modules/loader-runner/lib/LoaderRunner.js:367:11
    at /workspaces/angular-spring-sse-sample/client/node_modules/loader-runner/lib/LoaderRunner.js:203:19
    at VirtualFileSystemDecorator.readFile (/workspaces/angular-spring-sse-sample/client/node_modules/@ngtools/webpack/src/virtual_file_system_decorator.js:47:13)
    at processResource (/workspaces/angular-spring-sse-sample/client/node_modules/loader-runner/lib/LoaderRunner.js:202:11)
    at iteratePitchingLoaders (/workspaces/angular-spring-sse-sample/client/node_modules/loader-runner/lib/LoaderRunner.js:158:10)
    at runLoaders (/workspaces/angular-spring-sse-sample/client/node_modules/loader-runner/lib/LoaderRunner.js:365:2)
    at NormalModule.doBuild (/workspaces/angular-spring-sse-sample/client/node_modules/webpack/lib/NormalModule.js:295:3)
    at NormalModule.build (/workspaces/angular-spring-sse-sample/client/node_modules/webpack/lib/NormalModule.js:446:15)
    at Compilation.buildModule (/workspaces/angular-spring-sse-sample/client/node_modules/webpack/lib/Compilation.js:739:10)
    at /workspaces/angular-spring-sse-sample/client/node_modules/webpack/lib/Compilation.js:981:14 {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v19.9.0

Thanks StackOverflow

  1. export NODE_OPTIONS=--openssl-legacy-provider
  2. Now npm run start # works :-)

But now there is some other problem and I'm late... more later



Tags: programming, web

← Back home