Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web socket does not work in build for electron #101

Open
na-613c opened this issue Sep 22, 2021 · 11 comments
Open

Web socket does not work in build for electron #101

na-613c opened this issue Sep 22, 2021 · 11 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@na-613c
Copy link

na-613c commented Sep 22, 2021

I have a project on electron + react js + local node js server (use
rtsp-relay to convert RTSP stream to web socket). In the dev version it works, in the prod version the web socket does not work (the server is working, it was processing a get request)

I'm sorry for the bad english ☺

@na-613c na-613c changed the title web socket does not work in build for electron Web socket does not work in build for electron Sep 22, 2021
@k-yle
Copy link
Owner

k-yle commented Sep 22, 2021

Hi, do you have a example of this bug, perhaps a basic repository where I can test this? It's difficult to help without seeing any code.

@k-yle k-yle added the question Further information is requested label Sep 22, 2021
@na-613c
Copy link
Author

na-613c commented Sep 23, 2021

Hi.
https://github.com/na-613c/web-rtsp-relay-electron - repo.
In electron you can write mainWindow.webContents.openDevTools() (35 line) for open dev tools.

@na-613c
Copy link
Author

na-613c commented Sep 23, 2021

There is a memory leak, if you run a lot of streams in good quality, then you can see in the task dispatcher how RAM is spent over time.

@k-yle
Copy link
Owner

k-yle commented Sep 23, 2021

Is there any way of opening the dev tools in production? Pretty difficult to debug the issue otherwise

@na-613c
Copy link
Author

na-613c commented Sep 24, 2021

I just started learning electron. I don't know how to get the logs from the local server. 😞
p.s. added devtools (similar to browser) in prod.

@k-yle
Copy link
Owner

k-yle commented Sep 24, 2021

for some reason mainWindow.webContents.openDevTools() seems to have no effect in production.

Perhaps the issue is that in production, you're serving the react app from a file:// url, rather than from localhost...

@k-yle k-yle added the help wanted Extra attention is needed label Sep 24, 2021
@na-613c
Copy link
Author

na-613c commented Sep 25, 2021

You can delete process.env.NODE_ENV === 'development' in process.env.NODE_ENV === 'development' && mainWindow.webContents.openDevTools();
or download last version https://github.com/na-613c/web-rtsp-relay-electron/tree/2cb2e67f3beaa6121deb22328cd5ab07beadcab0.

Or something I didn't understand

@k-yle k-yle added bug Something isn't working and removed question Further information is requested labels Feb 13, 2022
@evalor
Copy link

evalor commented Jul 18, 2022

This may be caused by '@ffmpeg-installer/ffmpeg' package, It's a known issue that Asar breaks native paths. As a workaround, if you use Asar, you can do something like this:

const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path.replace('app.asar', 'app.asar.unpacked');

Since the relevant code is in this package, I cannot change it. Look here, I can only use translation tools to reply this issues. Forgive me for my poor English.

@k-yle
Copy link
Owner

k-yle commented Jul 19, 2022

Thanks for the suggestion @evalor, are you experiencing the same issue? I just tried the reproduction example from @na-613c (https://github.com/na-613c/web-rtsp-relay-electron), and it seems to work fine in production. Not sure why it didn't work 10 months ago...

@evalor
Copy link

evalor commented Jul 21, 2022

I use vite+vue3 to build electron application and encounter the same problem.

I try to change the following code( in index.js line 42 ):

    this.stream = spawn(
      ffmpegPath.replace('app.asar', 'app.asar.unpacked'),  // [!!!] It's changed here
      [
        ...(transport ? ['-rtsp_transport', transport] : []), // this must come before `-i [url]`, see #82
        '-i',
        url,
        '-f', // force format
        'mpegts',
        '-codec:v', // specify video codec (MPEG1 required for jsmpeg)
        'mpeg1video',
        '-r',
        '30', // 30 fps. any lower and the client can't decode it
        ...additionalFlags,
        '-',
      ],
      { detached: false, windowsHide },
    );

Now my application can work after it is built. Due to my busy work, I can't follow up this problem immediately. Later, I will try to provide a "minimal" problem recurrence code to help solve this problem.

By the way, you can enable the electron menu to open the developer tools. Please do not hide the menu bar. After starting the application, click 'View - > toggle developer tools' in the menu bar, the developer tool will open.

@evalor
Copy link

evalor commented Jul 25, 2022

Potential memory leaks may come from jsmpeg, on large (4K) RSTP streams, memory stack growth can be significantly observed, and applications will soon crash due to memory exhaustion. When I destroy instances of jsmpeg and recreate them every 10 minutes, this situation is suppressed. I'm trying to trace the source of memory leaks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants