Raised This Month: $32 Target: $400
 8% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
KyleS
SourceMod Plugin Approver
Join Date: Jul 2009
Location: Segmentation Fault.
Old 09-05-2017 , 03:01   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #31

https://sm.alliedmods.net/api/index....d=show&id=692&

The ADT_Array API doesn't support this behaviour either (see how with GetTrieValue the return is the state of the key, and the param is actually optional (well; should be)).

Anyways; yeah, in a bunch of plugins I do similar things with checking keys; this is definitely the more intuitive approach then erroring out if a single json key is missing (is this really the point of contention???).
KyleS is offline
rio_
Junior Member
Join Date: Feb 2017
Old 09-06-2017 , 01:02   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #32

Accelerator is telling me ripext is causing server crashes, can anyone confirm I'm reading this correctly? https://crash.limetech.org/yeyj445f3wip

Or could it be a false-positive? Either way, I have 7 crash reports like that from today. It says something about threads so HTTPClient must be causing it rather than the JSON stuff.
rio_ is offline
KyleS
SourceMod Plugin Approver
Join Date: Jul 2009
Location: Segmentation Fault.
Old 09-06-2017 , 13:06   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #33

Quote:
Originally Posted by rio_ View Post
Accelerator is telling me ripext is causing server crashes, can anyone confirm I'm reading this correctly? https://crash.limetech.org/yeyj445f3wip

Or could it be a false-positive? Either way, I have 7 crash reports like that from today. It says something about threads so HTTPClient must be causing it rather than the JSON stuff.
Yes, you're not the only person to ask/show that this extension is still very crashy.
KyleS is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 09-07-2017 , 11:12   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #34

Quote:
Originally Posted by rio_ View Post
Accelerator is telling me ripext is causing server crashes, can anyone confirm I'm reading this correctly? https://crash.limetech.org/yeyj445f3wip

Or could it be a false-positive? Either way, I have 7 crash reports like that from today. It says something about threads so HTTPClient must be causing it rather than the JSON stuff.
Could you explain what you're doing for these crashes? I was planning on doing just sending POST data to a java server, however this kind of stumps the idea if it's crashing the server.

edit: also what SM version were you using?

Last edited by Mitchell; 09-07-2017 at 11:58.
Mitchell is offline
rio_
Junior Member
Join Date: Feb 2017
Old 09-07-2017 , 17:16   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #35

I have a single HTTPClient with no extra headers and I'm making several GET requests at a time periodically, maybe something like every few minutes on average. The crashes are relatively infrequent relative to the amount of requests being made.

SM version is 1.9.0.6080.
rio_ is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 09-07-2017 , 17:22   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #36

Possible reference to 1.9 and crashes: https://forums.alliedmods.net/showpo...&postcount=324
However I don't know too much about this extension or what was added/changed in 1.9
Mitchell is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 10-01-2017 , 13:13   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #37

I think there's a leak within closing the HTTPClientObjects: (ignore the trie snapshot leak i've fixed it already)
Code:
L 09/23/2017 - 17:55:44: [SM] Unloading plugin to free 24279 handles.
L 09/23/2017 - 17:55:44: [SM] Contact the author(s) of this plugin to correct this error.
L 09/23/2017 - 17:55:44: --------------------------------------------------------------------------
L 09/23/2017 - 17:55:44: Type	GlobalFwd           |	Count	1
L 09/23/2017 - 17:55:44: Type	Trie                |	Count	2
L 09/23/2017 - 17:55:44: Type	TrieSnapshot        |	Count	21611
L 09/23/2017 - 17:55:44: Type	HTTPClientObject    |	Count	2652
L 09/23/2017 - 17:55:44: Type	JSONObject          |	Count	13
L 09/23/2017 - 17:55:44: -- Approximately 3379384 bytes of memory are in use by (24279) Handles.
If it helps heres the part of the code im using:
PHP Code:

        HTTPClient hHTTPClient 
= new HTTPClient("http://XXXXXX.xxx.xxx:8080");
        
hHTTPClient.SetHeader("authorization""Basic XXXXXXX");
        
hHTTPClient.Post("roundPost"mainRoundEventOnHTTPResponse);

public 
void OnHTTPResponse(HTTPResponse responseany value) {

Also this fails to connect to the webserver also (because it's not up currently). And the code executes on Round_End

Last edited by Mitchell; 10-01-2017 at 13:13.
Mitchell is offline
Deathknife
Senior Member
Join Date: Aug 2014
Old 10-01-2017 , 19:51   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #38

Quote:
Originally Posted by Mitchell View Post
I think there's a leak within closing the HTTPClientObjects: (ignore the trie snapshot leak i've fixed it already)
Code:
L 09/23/2017 - 17:55:44: [SM] Unloading plugin to free 24279 handles.
L 09/23/2017 - 17:55:44: [SM] Contact the author(s) of this plugin to correct this error.
L 09/23/2017 - 17:55:44: --------------------------------------------------------------------------
L 09/23/2017 - 17:55:44: Type	GlobalFwd           |	Count	1
L 09/23/2017 - 17:55:44: Type	Trie                |	Count	2
L 09/23/2017 - 17:55:44: Type	TrieSnapshot        |	Count	21611
L 09/23/2017 - 17:55:44: Type	HTTPClientObject    |	Count	2652
L 09/23/2017 - 17:55:44: Type	JSONObject          |	Count	13
L 09/23/2017 - 17:55:44: -- Approximately 3379384 bytes of memory are in use by (24279) Handles.
If it helps heres the part of the code im using:
PHP Code:

        HTTPClient hHTTPClient 
= new HTTPClient("http://XXXXXX.xxx.xxx:8080");
        
hHTTPClient.SetHeader("authorization""Basic XXXXXXX");
        
hHTTPClient.Post("roundPost"mainRoundEventOnHTTPResponse);

public 
void OnHTTPResponse(HTTPResponse responseany value) {

Also this fails to connect to the webserver also (because it's not up currently). And the code executes on Round_End
I believe HTTPClient isn't deleted by extension after response, only HTTPResponse and any data objects. HTTPClient is made so it can be re-used if main url is same and headers, and you just do .Post/.Get/etc on it when you want different path and input.
Either you should delete HTTPClient on response, or only form it once per host.
__________________
Deathknife is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 10-01-2017 , 20:32   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #39

Quote:
Originally Posted by Deathknife View Post
I believe HTTPClient isn't deleted by extension after response, only HTTPResponse and any data objects. HTTPClient is made so it can be re-used if main url is same and headers, and you just do .Post/.Get/etc on it when you want different path and input.
Either you should delete HTTPClient on response, or only form it once per host.
Ah, the test plugin was a bit misleading then, maybe it should show creating the HTTPClient and storing it as a global Handle etc. Thanks for the info though, plugin was working well while my webserver was up.
Mitchell is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 10-03-2017 , 06:12   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #40

I think the code examples in the second post are better examples than the test plugin, as they do show the HTTPClient being stored in a global variable, and they are well documented.
__________________
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
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:29.


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