Raised This Month: $12 Target: $400
 3% 

REST in Pawn 1.3 - HTTP client for JSON REST APIs (Updated 2021/08/22)


Post New Thread Reply   
 
Thread Tools Display Modes
Pavelas
Junior Member
Join Date: Oct 2016
Old 11-05-2020 , 02:42   Re: REST in Pawn 1.2 - HTTP client for JSON REST APIs (Updated 2020/09/13)
Reply With Quote #81

It looks really amazing, but maybe someone could tell me, which method is more efficient? MySQL or REST API? The main question here, what's better for server performance? Thank you!
Pavelas is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 11-06-2020 , 04:27   Re: REST in Pawn 1.2 - HTTP client for JSON REST APIs (Updated 2020/09/13)
Reply With Quote #82

I don't run any servers, so I don't know how it performs on a busy server, but I tested on a local server and was able to perform over 800 requests per second without noticing any performance issues. The extension also limits the number of requests it processes each frame, so even if you have several plugins performing hundreds of requests per second, it should not affect performance.

Also, this extension has been downloaded over 2000 times since the Weapon Stickers plugin was released, and I have not received any complaints.


If you're asking how this extension performs compared to MySQL, it depends. SourceMod can currently process maybe 25-30 queries per second, across all database connections. This extension can process over 700 requests per second on a single HTTP/2 connection. However, when using HTTP/1 each request uses its own connection, so it's much slower.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
digin
Member
Join Date: Nov 2019
Old 11-06-2020 , 06:26   Re: REST in Pawn 1.2 - HTTP client for JSON REST APIs (Updated 2020/09/13)
Reply With Quote #83

i use this extension on my servers for !vip, !agents, !tag, !chatcolors and others. thanks DJ Tsunami for making this extension
digin is offline
diller110
Junior Member
Join Date: Sep 2014
Old 11-23-2020 , 19:15   Re: REST in Pawn 1.2 - HTTP client for JSON REST APIs (Updated 2020/09/13)
Reply With Quote #84

Is it possible to add methods to check value type?
Something like here.
diller110 is offline
mr05je
New Member
Join Date: Dec 2020
Old 12-03-2020 , 09:31   Re: REST in Pawn 1.2 - HTTP client for JSON REST APIs (Updated 2020/09/13)
Reply With Quote #85

Hi, i have problem with SSL

Error: POST Error: Cert verify failed: BADCERT_NOT_TRUSTED

I'am trying to send request on localhost and idk how to fix this bug

Code:
JSONObject CreateJSONObject()
{
    JSONObject hJSONObject = new JSONObject();
    hJSONObject.SetString("steamId", "1");

    return hJSONObject;
}

public Action test(int client, int args)
{	
	
    JSONObject hJSONObject = CreateJSONObject();
    HTTPClient hHTTPClient = new HTTPClient("http://localhost:5000/Gang");
    
    hHTTPClient.Post("post", hJSONObject, OnHTTPResponse, 1);
}
P.S.:
I am bad at English, it is difficult for me because I live in Russia

Last edited by mr05je; 12-03-2020 at 09:31.
mr05je is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 12-09-2020 , 08:50   Re: REST in Pawn 1.2 - HTTP client for JSON REST APIs (Updated 2020/09/13)
Reply With Quote #86

Quote:
Originally Posted by mr05je View Post
Hi, i have problem with SSL

Error: POST Error: Cert verify failed: BADCERT_NOT_TRUSTED

I'am trying to send request on localhost and idk how to fix this bug

Code:
JSONObject CreateJSONObject()
{
    JSONObject hJSONObject = new JSONObject();
    hJSONObject.SetString("steamId", "1");

    return hJSONObject;
}

public Action test(int client, int args)
{	
	
    JSONObject hJSONObject = CreateJSONObject();
    HTTPClient hHTTPClient = new HTTPClient("http://localhost:5000/Gang");
    
    hHTTPClient.Post("post", hJSONObject, OnHTTPResponse, 1);
}
P.S.:
I am bad at English, it is difficult for me because I live in Russia
I can't reproduce this, are you sure you are using http://? You should only need a valid SSL certificate when using https://.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
tball
New Member
Join Date: Jan 2021
Old 01-26-2021 , 04:29   Re: REST in Pawn 1.2 - HTTP client for JSON REST APIs (Updated 2020/09/13)
Reply With Quote #87

Hi all

I couldn't find any documentation how to do this, and I don't have any experience in libcurl.

How do I change it, so it uses http/2 instead of http/1.1? I have some issue with http/1.1 getting rejected from my API with a chunk error. So I would like to try http/2 instead.

Thank you for this awesome extension.
tball is offline
tball
New Member
Join Date: Jan 2021
Old 01-26-2021 , 05:25   Re: REST in Pawn 1.2 - HTTP client for JSON REST APIs (Updated 2020/09/13)
Reply With Quote #88

Quote:
Originally Posted by tball View Post
Hi all

I couldn't find any documentation how to do this, and I don't have any experience in libcurl.

How do I change it, so it uses http/2 instead of http/1.1? I have some issue with http/1.1 getting rejected from my API with a chunk error. So I would like to try http/2 instead.

Thank you for this awesome extension.
Got it working, by changing the header...
tball is offline
BlackFart
Junior Member
Join Date: Feb 2021
Old 02-14-2021 , 15:34   Re: REST in Pawn 1.2 - HTTP client for JSON REST APIs (Updated 2021/02/07)
Reply With Quote #89

Hello,
This is the only extension I found for uploading files through http (demos recorded).
It doesn't seem like to work for me... (I found cURL, but it's not working for me either... )

Here is what I'm doing, calling CheckOldDemos() in OnMapStart()
Code:
HTTPClient httpClient;

public void CheckOldDemos()
{
    DirectoryListing  dl = OpenDirectory(newDemoPath);
    char newDemo[256];
    while(dl.GetNext(newDemo, sizeof(newDemo))) {
        if(SimpleRegexMatch(newDemo, ".*dem$") <= 0) {
            continue;
        }
        httpClient = new HTTPClient("localhost:8080/url");

        char demoPath[PLATFORM_MAX_PATH];
        BuildPath(Path_SM, demoPath, sizeof(demoPath), "data/image.jpg"); 

        httpClient.UploadFile("upload", demoPath, OnDemoUploaded); 
    }
}

void OnDemoUploaded(HTTPStatus status, any value)
{
    if (status != HTTPStatus_OK) {
        PrintToServer("Noooooooooooooo %d", status);
        return;
    }

    PrintToServer("Upload complete");
}
Nothing is printed from OnDemoUploaded(), the programm go through httpClient.UploadFile() without any error from what I can see, and I got nothing on my API

Thank for your help

EDIT: ok, after some tests, no example works... and I get no errors in the console I also tried with older version, so the issue isn't your last update 7 days ago... I really don't understand, even your example with a get doesn't work (it prints nothing)

Last edited by BlackFart; 02-14-2021 at 16:47.
BlackFart is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 02-15-2021 , 07:22   Re: REST in Pawn 1.2 - HTTP client for JSON REST APIs (Updated 2021/02/07)
Reply With Quote #90

Quote:
Originally Posted by BlackFart View Post
This is the only extension I found for uploading files through http (demos recorded).
Mind if I ask, how are you recording your demos in JPEG?

Quote:
Originally Posted by BlackFart View Post
It doesn't seem like to work for me... (I found cURL, but it's not working for me either... )
Sounds like PICNIC.


Quote:
Originally Posted by BlackFart View Post
Code:
    DirectoryListing  dl = OpenDirectory(newDemoPath);
    char newDemo[256];
    while(dl.GetNext(newDemo, sizeof(newDemo))) {
You're looping through, ... and getting the demo files into the "newDemo" variable?

Quote:
Originally Posted by BlackFart View Post
Code:
        char demoPath[PLATFORM_MAX_PATH];
        BuildPath(Path_SM, demoPath, sizeof(demoPath), "data/image.jpg"); 

        httpClient.UploadFile("upload", demoPath, OnDemoUploaded);
But you're still trying to upload "data/image.jpg" file, which with the BuildPath / Path_SM one would be the file @ "addons/sourcemod/data/image.jpg"?

... Is there any file at all, with the path "addons/sourcemod/data/image.jpg"?


In the end, with no errors, chances are the upload works just fine, and that it is your web url that may not work as expected.

... Is there anything running at all, on localhost, port 8080, and if so, what is the code over there?
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:00.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode