Recent

Author Topic: HTTP/2+HTTP/1.1+WebSocket server with Free Pascal  (Read 18710 times)

senglit

  • Full Member
  • ***
  • Posts: 131
Re: HTTP/2+HTTP/1.1+WebSocket server with Free Pascal
« Reply #15 on: January 13, 2022, 10:05:11 am »
hi,

when I tried to install it I got a error:oglregexprwrapper.pas(17,3) Fatal: Cannot find regexpr_t used by OGLRegExprWrapper of package commonutils_ilya2ik.
« Last Edit: January 13, 2022, 11:33:24 am by senglit »
I use Win10 + Lazarus 2.2.0 + FPC 3.2.2. All 64bit.

noszone

  • New Member
  • *
  • Posts: 46
Re: HTTP/2+HTTP/1.1+WebSocket server with Free Pascal
« Reply #16 on: January 13, 2022, 11:25:15 am »
Is your component fully supporting all major operaions? I mean is it safe to use it in live production project?

iLya2IK

  • New Member
  • *
  • Posts: 34
Re: HTTP/2+HTTP/1.1+WebSocket server with Free Pascal
« Reply #17 on: January 14, 2022, 01:11:00 pm »
hi,

when I tried to install it I got a error:oglregexprwrapper.pas(17,3) Fatal: Cannot find regexpr_t used by OGLRegExprWrapper of package commonutils_ilya2ik.

Hello.
The problem is caused by the fact that the current version of Lazarus uses an outdated RegExpr module. If your version of Lazarus already has REVersionMajor >= 1 in the RegExpr module, then it is correct to change two lines in module OGLRegExprWrapper:

Code: Pascal  [Select][+][-]
  1. {.$define regexpr_new}
  2. {$define regexpr_t}

to

Code: Pascal  [Select][+][-]
  1. {$define regexpr_new}
  2. {.$define regexpr_t}

Otherwise, it is strongly recommended to add all files from the folder "src" from repository https://github.com/andgineer/TRegExpr to the project folder or to the commonutils folder, and then rename regexpr.pas to regexpr_t.pas

If you do not want to download a new version of TRegExpr, you can limit yourself to the following change in OGLRegExprWrapper module
Code: Pascal  [Select][+][-]
  1. {.$define regexpr_new}
  2. {.$define regexpr_t}
« Last Edit: January 14, 2022, 03:51:51 pm by iLya2IK »

iLya2IK

  • New Member
  • *
  • Posts: 34
Re: HTTP/2+HTTP/1.1+WebSocket server with Free Pascal
« Reply #18 on: January 14, 2022, 01:45:39 pm »
Is your component fully supporting all major operaions? I mean is it safe to use it in live production project?

This product is just a convenient tool for realizing your specific needs - banking, shopping, streaming, etc. This server by itself cannot guarantee the security of transactions within your or any other external software - this product was not developed for this purpose. The business logic of such a live production project must be programmed by you yourself by, for example, connecting to a database management system with data replication, etc. Whereas WCHTTPServer will provide a platform and interface for your business logic to interact with the web. This product was developed by me for myself - to calculate engineering and scientific problems on a remote server. The server copes with this task regularly. Of course, it does not provide such a volume of features and a set of tools as many (non)commercial products, but in return it provides deep integration with the free pascal/lazarus development environment, reasonable query processing speed and ease of deployment on server hardware.

senglit

  • Full Member
  • ***
  • Posts: 131
Re: HTTP/2+HTTP/1.1+WebSocket server with Free Pascal
« Reply #19 on: January 21, 2022, 03:36:54 am »
It works! thank you!

hi,

when I tried to install it I got a error:oglregexprwrapper.pas(17,3) Fatal: Cannot find regexpr_t used by OGLRegExprWrapper of package commonutils_ilya2ik.

Hello.
The problem is caused by the fact that the current version of Lazarus uses an outdated RegExpr module. If your version of Lazarus already has REVersionMajor >= 1 in the RegExpr module, then it is correct to change two lines in module OGLRegExprWrapper:

Code: Pascal  [Select][+][-]
  1. {.$define regexpr_new}
  2. {$define regexpr_t}

to

Code: Pascal  [Select][+][-]
  1. {$define regexpr_new}
  2. {.$define regexpr_t}

Otherwise, it is strongly recommended to add all files from the folder "src" from repository https://github.com/andgineer/TRegExpr to the project folder or to the commonutils folder, and then rename regexpr.pas to regexpr_t.pas

If you do not want to download a new version of TRegExpr, you can limit yourself to the following change in OGLRegExprWrapper module
Code: Pascal  [Select][+][-]
  1. {.$define regexpr_new}
  2. {.$define regexpr_t}
I use Win10 + Lazarus 2.2.0 + FPC 3.2.2. All 64bit.

iLya2IK

  • New Member
  • *
  • Posts: 34
Re: HTTP/2+HTTP/1.1+WebSocket server with Free Pascal
« Reply #20 on: February 08, 2022, 12:51:26 pm »
Added a new example for WCHTTPServer.

REST Web Camera server

The server operates in the REST architecture mode. The server can accept POST requests and respond with JSON objects. The server is designed to collect images from cameras (devices) and forwards messages between devices to control the periphery via an HTTP 2 connection. A detailed implementation of an external device based on "ESP32-CAM" is given in the example webcamdevice. The example of a desktop application for external device controlling and viewing images is webcamclientviewer.

nicknikos

  • Newbie
  • Posts: 3
Re: HTTP/2+HTTP/1.1+WebSocket server with Free Pascal
« Reply #21 on: June 16, 2022, 09:33:04 am »
iLya2IK,

Congratulations for your excellent code!!
I' m really interested in using your contributed code in an internal application for serving various terminals with database data.
One question though..After i ran the tests (hpec,hload) the cpu load on Windows 10 pro 64 kept high (100%).The same hapens when connections arrive to the server (tested in all forms http,restjson,webcamserver). What should one do release the cpu utilization?

Thanks in advance!!

iLya2IK

  • New Member
  • *
  • Posts: 34
Re: HTTP/2+HTTP/1.1+WebSocket server with Free Pascal
« Reply #22 on: June 24, 2022, 07:01:53 am »
Congratulations for your excellent code!!

Thanks for your interest in my project  :)

After i ran the tests (hpec,hload) the cpu load on Windows 10 pro 64 kept high (100%).The same hapens when connections arrive to the server (tested in all forms http,restjson,webcamserver). What should one do release the cpu utilization?

Yes. Thanks to you, I noticed this error in the operation of the server in a Windows environment. The fact is that I program mainly in a Linux environment, and I haven't tested a server under Windows for a long time. Now I have made the necessary adjustments to the code of the wcNetworking.pas module, which, in my opinion, significantly reduced the load on the cpu.

As for the wcNetworking.pas module - in the TThread.Execute method used the Sleep(0) call - in a Windows environment, this caused a serious increase in CPU load. Sleep(0) I changed to Sleep(1).

iLya2IK

  • New Member
  • *
  • Posts: 34
Re: HTTP/2+HTTP/1.1+WebSocket server with Free Pascal
« Reply #23 on: December 12, 2022, 03:08:00 pm »
HTTP2 Web Cam Software Package

As an example of using this HTTP 2 server, a software package was developed and published for collecting and processing streaming data and messages from various devices using a single JSON subprotocol.
The software package includes a server and a package of client applications and libraries.

- wcwebcamserver (Lazarus/Free Pascal) is a server designed to collect images and data streams from cameras (devices) and forward messages between devices to control peripherals via an HTTP 2 connection.
- The abstract client for Lazarus is the curl client (Lazarus/Free Pascal).
- A detailed implementation of an external device based on "ESP32-CAM" is given in the example webcamdevice (C).
- An example of a desktop application for managing external devices and viewing images is webcamclientviewer (Lazarus).
- An example of an Android application for controlling external devices, chatting and streaming is wcwebcameracontrol (Java).

wcWebCamClient library API User's Guide

senglit

  • Full Member
  • ***
  • Posts: 131
Re: HTTP/2+HTTP/1.1+WebSocket server with Free Pascal
« Reply #24 on: February 20, 2024, 04:36:50 pm »
When I run the demo project the server rejected the connection from the browser. And I found these infos in the logwebtest.db:
table: log

Code: Text  [Select][+][-]
  1. 2024-02-20 14:07:45     9       1       Server started
  2. 2024-02-20 14:07:45     9       1       Server initialized
  3. 2024-02-20 14:07:45     9       2       Error (ESocketError) : Binding of socket failed: 8000
  4. 2024-02-20 14:07:45     9       2       Error (ESocketError) : Binding of socket failed: 8000
  5. 2024-02-20 14:07:45     9       2       Error (ESocketError) : Binding of socket failed: 8000
  6. ... and another 1,000+ same error message
  7.  

table: sessions
Code: Text  [Select][+][-]
  1. 1       2024-02-20 09:52:55
  2. 2       2024-02-20 09:55:17
  3. 3       2024-02-20 10:26:14
  4. 4       2024-02-20 10:26:42
  5. 5       2024-02-20 10:26:56
  6. 6       2024-02-20 13:48:08
  7. 7       2024-02-20 13:53:52
  8. 8       2024-02-20 13:54:03
  9. 9       2024-02-20 14:07:45
  10. 10      2024-02-20 15:18:33
  11.  

table: sqlite_sequence
Code: Text  [Select][+][-]
  1. sessions        10
  2. log     32670
  3.  

I didn't change anything in your demo project. I just put a zlib1.dll into system32 folder and put localhost.crt/csr into openssl folder to make it runable.

What did I possibly missing?
I use Win10 + Lazarus 2.2.0 + FPC 3.2.2. All 64bit.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: HTTP/2+HTTP/1.1+WebSocket server with Free Pascal
« Reply #25 on: February 22, 2024, 06:09:54 am »
Binding of socket failed: 8000
...
What did I possibly missing?
Something else is already listening on that port. You can use either netstat on cmd or Get-NetTCPConnection on PowerShell to see who. Or maybe just hit localhost:8000 in the browser and see what comes up.

senglit

  • Full Member
  • ***
  • Posts: 131
Re: HTTP/2+HTTP/1.1+WebSocket server with Free Pascal
« Reply #26 on: February 24, 2024, 01:32:44 pm »
Tried by another port 3333(ensured it's not ocupied by using Get-NetTCPConnection). But still can not connect. The request header is normal, but no response.

quite strange. Maybe something wrong with my zlib1.dll or localhost.crt/csr?

Binding of socket failed: 8000
...
What did I possibly missing?
Something else is already listening on that port. You can use either netstat on cmd or Get-NetTCPConnection on PowerShell to see who. Or maybe just hit localhost:8000 in the browser and see what comes up.
I use Win10 + Lazarus 2.2.0 + FPC 3.2.2. All 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 14214
  • Probably until I exterminate Putin.
Re: HTTP/2+HTTP/1.1+WebSocket server with Free Pascal
« Reply #27 on: February 24, 2024, 01:41:33 pm »
if i read zlib combined with dll I get worried.  Why will people simply abandon it?
Specialize a type, not a var.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: HTTP/2+HTTP/1.1+WebSocket server with Free Pascal
« Reply #28 on: February 25, 2024, 09:36:09 am »
Tried by another port 3333(ensured it's not ocupied by using Get-NetTCPConnection). But still can not connect. The request header is normal, but no response.

quite strange. Maybe something wrong with my zlib1.dll or localhost.crt/csr?
Is it still the "Binding of socket failed" error?

 

TinyPortal © 2005-2018