Websockets arre not automatically closed

zactyson64

Client
Регистрация
18.03.2019
Сообщения
43
Благодарностей
3
Баллы
8
Hello, there's a bug that I found that happens even in the Project Maker, the bug is with websocket connections, the websocket connections created with C# own code are not terminated properly when the thread/task is completed, the websocket connection will still run in the background unless you manually close ZennoPoster/Project Maker and only then the connection will be terminated
 

Phoenix78

Client
Read only
Регистрация
06.11.2018
Сообщения
11 790
Благодарностей
5 689
Баллы
113
Why don 't you close it yourself ?
How should the Zennoposter know that you have a socket open?
Why don't you lay out the C# code so that experts can look at it and advise something specifically, and not guess on the coffee grounds?
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 770
Благодарностей
1 180
Баллы
113

VladZen

Administrator
Команда форума
Регистрация
05.11.2014
Сообщения
22 215
Благодарностей
5 843
Баллы
113
We do not fully support websockets out-of-the-box actually.
If you set up websocket connection via own code, you should manage it by yourself.
We consider to add websocket support in ZennoPoster 8.
 

zactyson64

Client
Регистрация
18.03.2019
Сообщения
43
Благодарностей
3
Баллы
8
Developers of the code are responsible for closing connections usually.
You also dispose file stream, you dispose db connections, in any project you develop.
this is not a bug.

Below some docs about it.

ex. FileStream.Dispose(Boolean) Method (System.IO) | Microsoft Learn
ex. WebSocket.Dispose Method (System.Net.WebSockets) | Microsoft Learn
The problem isn't that I don't want to close the websocket, it's that I need to have the websocket connection open while the thread is running. so it creates a websocket connection then goes on to another task in the same thread that are not related to the websocket and I'm not sure how would I access the websocket that was just opened again to close it as the last task in the thread, is there documentation about that in zennoposter?
 

zactyson64

Client
Регистрация
18.03.2019
Сообщения
43
Благодарностей
3
Баллы
8
Why don 't you close it yourself ?
How should the Zennoposter know that you have a socket open?
Why don't you lay out the C# code so that experts can look at it and advise something specifically, and not guess on the coffee grounds?
When I execute the code through C# own code, it finishes executing and then I don't have access to the connection to close it or is there maybe a way to access it even after the C# block is executed? If there's a way please tell me how. the project does more tasks after opening the socket and the socket will need to stay open during that execution but when the whole thread is done and is terminated, the socket should also terminate, the socket will terminate when I close zennoposter.exe or projectmaker.exe as of now, why this behavior isn't done when the individual threads are terminated?
 

Phoenix78

Client
Read only
Регистрация
06.11.2018
Сообщения
11 790
Благодарностей
5 689
Баллы
113
When I execute the code through C# own code, it finishes executing and then I don't have access to the connection to close it or is there maybe a way to access it even after the C# block is executed? If there's a way please tell me how. the project does more tasks after opening the socket and the socket will need to stay open during that execution but when the whole thread is done and is terminated, the socket should also terminate, the socket will terminate when I close zennoposter.exe or projectmaker.exe as of now, why this behavior isn't done when the individual threads are terminated?
how should I know ? I'm not guessing on the coffee grounds. As I already wrote, give a working example, someone will look. Maybe you are running a parallel task that is not related to the current thread at all, or maybe not.
 

Alexmd

Client
Регистрация
10.12.2018
Сообщения
1 021
Благодарностей
1 383
Баллы
113
Вы должны понимать что такое области видимости в программировании и понимать, как они работают в зенке, и уже исходя из этого конструировать логику работы отдельного потока, запущенного в общем коде, в данном случае вебсокета.
Ответ на Ваш вопрос есть в конкурсной статье по асинхронным вебсокетам. https://zennolab.com/discussion/threads/asinxronnyj-websocket-dlja-vas-i-vashix-blizkix.70182/ Просто создайте флаг, который будет проверять поток вебсокета в цикле своей работы.
Ответственность за закрытие запущенных потоков всегда была на программисте, который их открывал.
ps. hope you can use google translate :-)
 
  • Спасибо
Реакции: Phoenix78

VladZen

Administrator
Команда форума
Регистрация
05.11.2014
Сообщения
22 215
Благодарностей
5 843
Баллы
113
Вы должны понимать что такое области видимости в программировании и понимать, как они работают в зенке, и уже исходя из этого конструировать логику работы отдельного потока, запущенного в общем коде, в данном случае вебсокета.
Ответ на Ваш вопрос есть в конкурсной статье по асинхронным вебсокетам. https://zennolab.com/discussion/threads/asinxronnyj-websocket-dlja-vas-i-vashix-blizkix.70182/ Просто создайте флаг, который будет проверять поток вебсокета в цикле своей работы.
Ответственность за закрытие запущенных потоков всегда была на программисте, который их открывал.
ps. hope you can use google translate :-)
вы тоже можете использовать гугл транслейт для ответа:-)
 
  • Спасибо
Реакции: lokiys

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)