GithubHelp home page GithubHelp logo

southclaws / pawn-requests Goto Github PK

View Code? Open in Web Editor NEW
67.0 8.0 19.0 282 KB

pawn-requests provides an API for interacting with HTTP(S) JSON APIs.

License: MIT License

CMake 2.86% C++ 46.82% Pawn 49.05% Earthly 1.26%
sa-mp sa-mp-plugin sa-mp-development pawn-package requests http-client http-requests

pawn-requests's People

Contributors

adrfranklin avatar agraber avatar alextwothousand avatar alilogic avatar bigeti avatar southclaws avatar ziggi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pawn-requests's Issues

Failed

Hello, how to fix this error? I tried to compile everything on my server but it did not help.

[19:23:28] Server Plugins
[19:23:28] --------------
[19:23:28]  Loading plugin: requests.so
[19:23:28]   Failed (plugins/requests.so: symbol _ZNKSt3_V214error_category10_M_messageB5cxx11Ei, version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference)
[19:23:28]  Loaded 0 plugins.

gcc version 4.8.5 (Ubuntu 4.8.5-4ubuntu8~14.04.2)

File or function not found for JsonArrayLength

What is the Problem?

The function JsonArrayLength seems to be still not implemented right.

What did you try to resolve the error ?

  1. Tried to reload the plugin with the sampctl command line tool with sampctl package ensure and sampctl server ensure
  2. Tried to delete the plugin files that where already present
  3. Tried to add the dependencies manually with the files from the newest release
  4. Tried the function in a clean gamemode, so there would be no interference with other plugins or code

Deprecate incorrectly named "Append" and implement "Push", "Concat" and "Merge"

After some confusion I've realised that the JsonAppend function is named incorrectly!

Appending is adding a single item to a collection of items however the current API expects the input and destination to either be both arrays or both objects. This is actually concatenation not appending.

So, the existing JsonAppend function should be marked deprecated and two new functions introduced:

  • JsonPush this is purely for arrays where you want to push a single item to the end.
  • JsonConcat does exactly what JsonAppend does but only for arrays.
  • JsonMerge does exactly what JsonAppend does but only for objects.

Are Requests executed in multithreading?

I have the code:

Request(); // id 0
Request(); // id 1

// Callback for Requests id 0 and id 1
public CallbackRequests() { printf("[RequestXF:%d]", id); }

But these Request() executions happen in a random order. For me, order in this case is very important. What can I do about it?
console test 1: [RequestXF:1] [RequestXF:0]
console test 2: [RequestXF:0] [RequestXF:1]

UPD: I found a solution to how I can get rid of several requests in a row. But this problem is relevant in the future.

Crashes when trying to use JsonString on specific codepages

a´´á encoded in Windows-1252 is enough to make JsonString crash:

[06/10/18 04:26:07] [CMD] Adrian_Graber (19837): /a a´´á
[06/10/18 04:26:07] [debug] Server crashed while executing dx.amx
[06/10/18 04:26:07] [debug] AMX backtrace:
[06/10/18 04:26:07] [debug] #0 native JsonString () in requests.DLL
[06/10/18 04:26:07] [debug] #1 0003a944 in @yH_OnAdminChatMessage@005 (playerid=0, name[]=@02ce3fa4 "Adrian_Graber", message[]=@02ce3f90 "a") at dx\core\discord\impl.inc:37
[06/10/18 04:26:07] [debug] #2 00014004 in public OnAdminChatMessage (0, 47071140, 47071120) at C:\DixelRP\dependencies\YSI-Includes\YSI_Coding\y_inline\..\y_cgen\y_cgen.inc:127
[06/10/18 04:26:07] [debug] #3 native CallLocalFunction () in samp-server.exe
[06/10/18 04:26:07] [debug] #4 0013d9a4 in main (playerid=0, params[]=@02ce3f7c "a") at C:\DixelRP\gamemodes\dx.pwn:2635
[06/10/18 04:26:07] [debug] Native backtrace:
[06/10/18 04:26:07] [debug] #0 77e7d28b in ?? () in C:\Windows\SYSTEM32\ntdll.dll
[06/10/18 04:26:07] [debug] #1 77e4c716 in ?? () in C:\Windows\SYSTEM32\ntdll.dll
[06/10/18 04:26:07] [debug] #2 6f444796 in ?? () in C:\Windows\SYSTEM32\VCRUNTIME140.dll
[06/10/18 04:26:07] [debug] #3 581ea6d6 in ?? () in cpprest_2_10.dll
[06/10/18 04:26:07] [debug] #4 004010b6 in ?? () in samp-server.exe
[06/10/18 04:26:07] [debug] #5 610892dc in ?? () in plugins\crashdetect.DLL
[06/10/18 04:26:07] [debug] #6 60ed88bc in ?? () in plugins\streamer.DLL
[06/10/18 04:26:07] [debug] #7 59329663 in ?? () in plugins\pawnraknet.DLL

I’m currently working around this using utf8encode from strlib, but crashing the server isn’t very nice...

Error in SSL handshake

Hello,

While compiling and running on both Archlinux (sampctl version 1.8.39) and Ubuntu 18.04 I came across this error:
ERROR: HTTP error Error in SSL handshake. I saw the issue #34 but it didn't helped. I saw an issue related to cpprestsdk (Azure/azure-storage-cpp#197) and putting a symlink for /usr/local/ssl to /etc/ssl did the trick on Archlinux. I don't know why it doesn't check in /etc/ssl as it seems standard.

I don't know if you have a solution for this, but anyway it may help some people to solve this issue.

randomly server freeze / crash

Greetings! I have random problems using the plugin. Quite accidentally, the plugin may start flooding in server_log.txt with the following error:
ERROR: failed to dispatch request thread: 'std::exception'

There are a lot of such lines.

During this flood, the server simply freezes and unfreeze only after the flood stops.

But in addition to a simple freeze, the server may crash with the following reason:


[14: 32: 12] ERROR: failed to dispatch request thread: 'std::exception'
[14:32:12] [debug] Server crashed due to an unknown error
[14:32:12] [debug] Native backtrace:
[14:32:12] [debug] #0 f7a36ed6 in _Z13GetStackTraceRSt6vectorI10StackFrameSaIS0_EEPv () from plugins/crashdetect.so
[14:32:12] [debug] #1 f7a2f210 in _ZN18CrashDetectHandler20PrintNativeBacktraceERSoRKN2os7ContextE () from plugins/crashdetect.so
[14:32:12] [debug] #2 f7a3005c in _ZN18CrashDetectHandler20PrintNativeBacktraceERKN2os7ContextE () from plugins/crashdetect.so
[14:32:12] [debug] #3 f7a30bb6 in _ZN18CrashDetectHandler7OnCrashERKN2os7ContextE () from plugins/crashdetect.so
[14:32:12] [debug] #4 f7a365c2 in ?? () from plugins/crashdetect.so
[14:32:12] [debug] #5 f7f28f10 in __kernel_rt_sigreturn () from linux-gate.so.1
[14:32:12] [debug] #6 f7f28ee9 in __kernel_vsyscall () from linux-gate.so.1
[14:32:12] [debug] #7 f7a92566 in gsignal () from /lib/libc.so.6
[14:32:12] [debug] #8 f7a7a3b5 in abort () from /lib/libc.so.6
[14:32:12] [debug] #9 f7d7fb84 in ?? () from /lib/libstdc++.so.6
[14:32:12] [debug] #10 f7d8da68 in ?? () from /lib/libstdc++.so.6
[14:32:12] [debug] #11 f7d8daf1 in ?? () from /lib/libstdc++.so.6
[14:32:12] [debug] #12 f7d8de30 in __cxa_rethrow () from /lib/libstdc++.so.6
[14:32:12] [debug] #13 f7d7f6f9 in ?? () from /lib/libstdc++.so.6
[14:32:12] [debug] #14 f5e7ffde in _ZNSt6vectorIN4Impl12ResponseDataESaIS1_EE19_M_emplace_back_auxIJRKS1_EEEvDpOT_ () from plugins/requests.so
[14:32:12] [debug] #15 f5e6d7ed in _ZN4Impl15gatherResponsesEv () from plugins/requests.so
[14:32:12] [debug] #16 f5e974e9 in _ZN7Natives11processTickEP6tagAMX () from plugins/requests.so
[14:32:12] [debug] #17 f5e6bd3b in ProcessTick () from plugins/requests.so
[14:32:12] [debug] #18 080d1ce2 in ?? () from ./samp03svr
[14:32:12] [debug] #19 080aef3a in ?? () from ./samp03svr
[14:32:12] [debug] #20 080aa13a in ?? () from ./samp03svr
[14:32:12] [debug] #21 f7a7bebe in __libc_start_main () from /lib/libc.so.6
[14:32:12] [debug] #22 0804b4e1 in ?? () from ./samp03svr
[14:32:12] [debug] Registers:
[14:32:12] [debug] EAX: 00000000 EBX: 00000002 ECX: fffa3e9c EDX: 00000000
[14:32:12] [debug] ESI: 00000008 EDI: 00000000 EBP: fffa3e9c ESP: fffa3e80
[14:32:12] [debug] EIP: f7f28ee9 EFLAGS: 00200246
[14:32:12] [debug] Stack:
[14:32:12] [debug] ESP+00000000: fffa3e9c 00000000 fffa3e9c f7a92566
[14:32:12] [debug] ESP+00000020: 00000000 00000000 ffffffec 00000001
[14:32:12] [debug] ESP+00000040: fffffff0 00000001 fffffff4 00000001
[14:32:12] [debug] ESP+00000060: 00000000 00000000 00000000 00000000
[14:32:12] [debug] ESP+00000080: 00000000 f7f34d5c f7a74a53 f7d68727
[14:32:12] [debug] ESP+000000a0: fffffffe ffffffff ffffffff ffffffff
[14:32:12] [debug] ESP+000000c0: ffffffff ffffffff ffffffff ffffffff
[14:32:12] [debug] ESP+000000e0: ffffffff ffffffff ffffffff ffffffff
[14:32:12] [debug] ESP+00000100: ffffffff ffffffff ffffffff ffffffff
[14:32:12] [debug] ESP+00000120: 00000000 00000000 f7f1b910 f7a5b940
[14:32:12] [debug] ESP+00000140: 00000006 fffa3fd0 00000000 fffa3fd4
[14:32:12] [debug] ESP+00000160: 00000000 00000000 00000000 00000000
[14:32:12] [debug] ESP+00000180: 00000000 00000000 00000000 00000000
[14:32:12] [debug] ESP+000001a0: 00000000 00000000 00000000 00000000
[14:32:12] [debug] ESP+000001c0: 00000000 00000000 00000000 00000000
[14:32:12] [debug] ESP+000001e0: 0000000a 0000000a fffa40e8 f7adc30f
[14:32:12] [debug] ESP+00000200: f7eed030 f7f3adfa f7d23c60 f7f1a580
[14:32:12] [debug] ESP+00000220: 00000005 00000000 fffa40e8 f7ad6afa
[14:32:12] [debug] ESP+00000240: f7f3ad4d f7a66d8c f7eed000 f7d8cb0f
[14:32:12] [debug] ESP+00000260: fffa4138 f7f411c4 f7a5b930 f7eed000
[14:32:12] [debug] ESP+00000280: fffa4134 f7f1a740 f7e812f4 f7e812e2
[14:32:12] [debug] ESP+000002a0: f7f54fcc f7d01000 f7eed000 f7eed000
[14:32:12] [debug] ESP+000002c0: f7f3ad4d f7eed000 173fdef0 f7d8daf1
[14:32:12] [debug] ESP+000002e0: 00000000 f7d8dada f7eed000 f7d8de30
[14:32:12] [debug] ESP+00000300: f7eed000 00800000 00400000 f7d7f6f9
[14:32:12] [debug] ESP+00000320: f7d8e3f0 f6222000
f6222000 f5e7ffde
[14:32:12] [debug] ESP+00000340: 00aa16eb f7e32e7a f7ae1d8b f7eed000
[14:32:12] [debug] ESP+00000360: a6005640 f7f28e2e f5e7ff89 f6222000
[14:32:12] [debug] ESP+00000380: fffa42e4 fffa4230 f622d480 f5e6d682
[14:32:12] [debug] ESP+000003a0: fffa4234 fffa4230 fffa4230 f6222000
[14:32:12] [debug] ESP+000003c0: 53636e79 65767265 3aaa0072 000000c8
[14:32:12] [debug] ESP+000003e0: 00aa16eb 00000000 82b50889 00000000
[14:32:12] [debug] Loaded modules:
[14:32:12] [debug] 00000000 - 00187dc3 samp03svr
[14:32:12] [debug] f7f28000 - f7f2911c linux-gate.so.1
[14:32:12] [debug] f7f14000 - f7f17140 /lib/libdl.so.2
[14:32:12] [debug] f7ef1000 - f7f11777 /lib/libpthread.so.0
[14:32:12] [debug] f7d01000 - f7efc9be /lib/libstdc++.so.6
[14:32:12] [debug] f7c2f000 - f7cff0d8 /lib/libm.so.6
[14:32:12] [debug] f7c11000 - f7c2c874 /lib/libgcc_s.so.1
[14:32:12] [debug] f7a5d000 - f7c160bc /lib/libc.so.6
[14:32:12] [debug] f7f2a000 - f7f553e3 /lib/ld-linux.so.2
[14:32:12] [debug] f7a18000 - f7a59e08 plugins/crashdetect.so
[14:32:12] [debug] f78d0000 - f7a1c440 plugins/pawnraknet.so
[14:32:12] [debug] f753f000 - f78d4eb2 plugins/mysql.so
[14:32:12] [debug] f751b000 - f753ed32 /home/lsgame/samp03/plugins/../log-core.so
[14:32:12] [debug] f7510000 - f7518393 /lib/librt.so.1
[14:32:12] [debug] f63ec000 - f63fe004 /lib/libnss_files.so.2
[14:32:12] [debug] f6327000 - f63ebbcf plugins/streamer.so
[14:32:12] [debug] f6317000 - f63261d4 plugins/sscanf.so
[14:32:12] [debug] f6232000 - f631a3e9 plugins/pawncmd.so
[14:32:12] [debug] f5d27000 - f625479c plugins/requests.so
[14:32:12] [debug] f7f1e000 - f7f217a0 plugins/TOTP.so
[14:32:12] [debug] f650b000 - f650cdf4 plugins/CRP.so
[14:32:12] [debug] f5d1a000 - f5d26011 plugins/gvar.so
[14:32:12] [debug] f5cb5000 - f5d19e6e plugins/regex.so
[14:32:12] [debug] f6503000 - f6508892 plugins/filemanager.so

OS: Fedora 32

Plugin

can someone send requests.so and .dll I can not build

Russian characters in response

Hey.

Are they supported? Currently getting something like that.
Снимок экрана 2020-04-14 в 1 13 53 PM

Is there is some ways to convert UTF-8 to CP1251 (or ansi? i don't actually know how it's called)

CP1251 works well in SAMP, but UTF-8 string doesn't. :(

Container build fails with `dl` link fail

[ 90%] Linking CXX executable ../../Binaries/SearchFile
/root/openssl-1.0.2o/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x16): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x2c): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x36): undefined reference to `dlclose'
/root/openssl-1.0.2o/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x396): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x419): undefined reference to `dlerror'
/root/openssl-1.0.2o/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
dso_dlfcn.c:(.text+0x4a8): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x53d): undefined reference to `dlerror'
/root/openssl-1.0.2o/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
dso_dlfcn.c:(.text+0x5b3): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x61b): undefined reference to `dlclose'
dso_dlfcn.c:(.text+0x650): undefined reference to `dlerror'
/root/openssl-1.0.2o/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x6e0): undefined reference to `dladdr'
dso_dlfcn.c:(.text+0x739): undefined reference to `dlerror'
/root/openssl-1.0.2o/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
dso_dlfcn.c:(.text+0x7a4): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
make[2]: *** [Binaries/SearchFile] Error 1
samples/SearchFile/CMakeFiles/SearchFile.dir/build.make:106: recipe for target 'Binaries/SearchFile' failed
CMakeFiles/Makefile2:1064: recipe for target 'samples/SearchFile/CMakeFiles/SearchFile.dir/all' failed
Makefile:140: recipe for target 'all' failed
make[1]: *** [samples/SearchFile/CMakeFiles/SearchFile.dir/all] Error 2
make: *** [all] Error 2

Crash on fails WebSocket connection

WebSocketClient/JsonWebSocketClient function causes the crash if a connection to WebSocket server was not established. Also, the loss of the established connection causes crash.

[15/06/2018 03:40:36] [debug] Server crashed while executing test.amx
[15/06/2018 03:40:36] [debug] AMX backtrace:
[15/06/2018 03:40:36] [debug] #0 native WebSocketClient () from requests.DLL
[15/06/2018 03:40:36] [debug] #1 0001601c in WebSocketInit () at test.pwn:108
[15/06/2018 03:40:36] [debug] #2 00056aa4 in public OnGameModeInit () at test.pwn:88
[15/06/2018 03:40:37] [debug] Native backtrace:
[15/06/2018 03:40:37] [debug] #0 77ecd97a in ?? () from C:\Windows\SYSTEM32\ntdll.dll
[15/06/2018 03:40:37] [debug] #1 77e9b9b6 in ?? () from C:\Windows\SYSTEM32\ntdll.dll
[15/06/2018 03:40:37] [debug] #2 6e4504db in ?? () from C:\Windows\SYSTEM32\MSVCP140.dll
[15/06/2018 03:40:37] [debug] #3 6baa6b06 in ?? () from plugins\requests.DLL
[15/06/2018 03:40:37] [debug] #4 6baacc61 in ?? () from plugins\requests.DLL
[15/06/2018 03:40:37] [debug] #5 6baa7a96 in ?? () from plugins\requests.DLL
[15/06/2018 03:40:37] [debug] #6 6baad9e8 in ?? () from plugins\requests.DLL
[15/06/2018 03:40:37] [debug] #7 6baa096c in ?? () from plugins\requests.DLL
[15/06/2018 03:40:37] [debug] #8 6bab26be in ?? () from plugins\requests.DLL
[15/06/2018 03:40:37] [debug] #9 004010b6 in ?? () from samp-server-cr.exe
[15/06/2018 03:40:37] [debug] #10 6c1ad60a in ?? () from plugins\crashdetect.DLL

ERROR: HTTP error Error in SSL handshake

I compiled plugin successfully on my virtual machine, I had to update websocket. I use this plugin because I want to send messages from samp server to discord channel using discord's webhook.

//OnGameModeInit
gDiscordWebhook = RequestsClient("https://discordapp.com/api/webhooks/635572759094755338/oqP-j3mJuAMSiRJ3CujcoJVo7GrcqdqAJ_ydaU4-3KOL7Z3f_TOltHaM5raJig9J8uP_");

On my localhost (Windows 7, 64bit) it works, the message is sent to discord channel. On Linux machine (Debian 8, 32bit) it fails, with error in server-log file

ERROR: HTTP error Error in SSL handshake

Is this related to my build or the machine problem? Maybe user doesn't have access to somewhere ? I am new to this thing, do you know what I can do about it?

Refactor the library and make it easier to use

Hello, it seems like like this library was inspired by the python's request library. But there are many things which could be improved in this library so that it's more easier to use (and it has a lot of potential and possibly can be the standard for making HTTP requests in the near future)

What I want to suggest is to send requests like this ( a blocking call )

response = requests.post(url, body, headers);
OR
response = requests.get(url, headers);

if (response.status_code == HTTP_STATUS_OK):
    data = response.data;
    * do some operations *

Or if you want to have a callback associated with it ( non blocking call )

requests.post(url, body, headers, callback=callback_func, callback_params=params);
public callback_func(response, params){
if (response.status_code == 200)
    * do some operations *
}

Is it possible? I am also interested in contributing if you want. Thanks!

Error

Failed (/lib/i386-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by plugins/requests.so))

Problem parsing JSON

When parsing a received a JSON from Java (Spring) REST service it doesn't receive nothing. I thought it was because of nulls on Json, so i filled them with empty strings and arrays but still.

Java Entity

@Entity
public class Usuario implements Serializable {

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;

  @Column
  @NotNull
  private String username;

  @Column
  @NotNull
  private String contrasenia;

  @Column
  private String correo;

  @Column
  private Date fechaAlta;

  @Column
  private Float salud;

  @Column
  private Float blindaje;

  @Column
  private Integer energia;

  @Column
  private Integer saciedadHambre;

  @Column
  private Integer conectado;

  @JoinColumn
  @ManyToOne
  private Crew crew;

  @JoinColumn
  @ManyToOne
  private RangoCrew rangoCrew;


  @JoinColumn
  @OneToMany(fetch = FetchType.LAZY)
  private List<Vehiculo> vehiculoList;

  @JoinColumn
  @OneToMany(fetch = FetchType.LAZY)
  private List<Propiedad> propiedadList;

  @JoinColumn
  @OneToMany(fetch = FetchType.LAZY)
  private List<ItemInventario> itemInventarioList;

  @JoinColumn
  @ManyToMany(fetch = FetchType.LAZY)
  private List<Afeccion> afeccionList;
}

Java REST:

@PostMapping("findUsuarioByUsername")
  public Usuario findUsuarioByUsername(@RequestBody Map<String, String> body) {

    String username = body.get("username");

    return usuarioRepository.findUsuarioByUsername(username);
  }

JSON comming from service (Not null protected):

{
    "username": "Elba_Nanero",
    "contrasenia": "lala",
    "correo": null,
    "fechaAlta": null,
    "salud": null,
    "blindaje": null,
    "energia": null,
    "saciedadHambre": null,
    "conectado": 1,
    "crew": null,
    "rangoCrew": null,
    "vehiculoList": null,
    "propiedadList": null,
    "itemInventarioList": null,
    "afeccionList": null
}

Json null protected

{
    "username": "Elba_Nanero",
    "contrasenia": "lala",
    "correo": "asdasd",
    "fechaAlta": "2018-11-22T13:11:30.996+0000",
    "salud": 0,
    "blindaje": 0,
    "energia": 0,
    "saciedadHambre": 0,
    "conectado": 1,
    "crew": {},
    "rangoCrew": {},
    "vehiculoList": [],
    "propiedadList": [],
    "itemInventarioList": [],
    "afeccionList": []
}

SAMP - Request:

public OnGameModeInit()
{
client = RequestsClient("http://localhost:8080/", RequestHeaders(
        "Content-Type", "application/json",
        "Accept", "application/json"
   	));
    
    new Node:node = JsonObject("username", JsonString("Elba_Nanero"));
    
	RequestJSON(client, "usuario/findUsuarioByUsername", HTTP_METHOD_POST, "OnServerResponse", node, RequestHeaders("Content-Type", "application/json",
        "Accept", "application/json"));
return 1;

}

SAMP - Process Response:

public OnServerResponse(id, status, node) {

	new strResponse[512];
	new strData[128];
	
    JsonGetString(node, "contrasenia", strData);
	format(strResponse, 512, "Recibi: '%s'", strData);
	print(strResponse);
}

SAMP - Error | Empty
image

A little hand please?

Also, the status code is 2 (WTF)

image


Update

After some testing, i found out that only strings are the problem. Look at this:

image

Float and Integers work fine Neither float and integers are working, they come as "0" always

Docker on 32bit system

Hi, I try to run pawn-requests plugin on my server, but it fails

[21.10.2019 10:20:47]  Loading plugin: requests.so
[21.10.2019 10:20:47]   Failed (/usr/lib/i386-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by plugins/requests.so))

So I try to compile the plugin on my virtual machine (debian 8, 32bit). The problem is docker, can it be installed on 32bit system? I've done some research and found this, although after sudo bash build-image.sh command, I get errors

Package docker.io is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'docker.io' has no installation candidate
build-image.sh: linia 16: debootstrap: not found
build-image.sh: linia 19: /var/chroot/jessie/etc/apt/sources.list: not found
chroot: cannot change directory root na /var/chroot/jessie: not found

tar: /var/chroot/jessie: Nie można open: not found
tar: Error is not recoverable: exiting now

Is the docker a must-have or there is other option to build the plugin without docker?

Run time error 19: "File or function is not found"

[09:17:33]  Loading plugin: requests
[09:17:33]   Failed.
[09:17:33] [debug] Run time error 19: "File or function is not found"
[09:17:33] [debug]  JsonCleanup
[09:17:33] [debug]  RequestHeaders
[09:17:33] [debug]  RequestsClient
[09:17:33] [debug]  RequestJSON
[09:17:33] [debug]  JsonGetString
[09:17:33] [debug]  JsonGetInt
[09:17:33] [debug] Run time error 19: "File or function is not found"
[09:17:33] [debug]  JsonCleanup
[09:17:33] [debug]  RequestHeaders
[09:17:33] [debug]  RequestsClient
[09:17:33] [debug]  RequestJSON
[09:17:33] [debug]  JsonGetString
[09:17:33] [debug]  JsonGetInt
[09:17:33] Script[gamemodes/vinland-rp.amx]: Run time error 19: "File or function is not found"

I do not know why, but requests.DLL failed to load, I placed all files from dependencies folder to System32 folder...

Freezes Randomly

My server freezes randomly, from 2x a day, to 1x a day, or even a whole day without any. In the event of a freeze, I am forced to turn it off and on again, as it does not defrost on its own. The 'Crashdetect' does not report any from gamemode function that may be "slow" at the time of freezing.

Q: How do I know the problem may have to do with this plugin (requests)?
A: I tested the server without this plugin (requests) for 1 week and the problem did not occur.

plugin version used: 0.10.0
Operating System: Windows Server 2019
Plugins used:
mysql
discord-connector
sampvoice
log-plugin
sscanf
MapAndreas
streamer
chrono
SAMPSON - some old scripts (includes) still use this plugin, can it be conflicted with a plugin requests?
pawncmd
pawnregex
pawnraknet
pawn-memory
requests

sampctl package build / test - failed to compile package entry: exit status 3221226505

Tried here Southclaws/sampctl#282 but the help website isnt online anymore.

How to reproduce that:

  • Clone pawn-request
  • Do command: sampctl p ensure
  • Do command: sampctl p (build/run) --verbose --forceEnsure --platform windows

Command: sampctl p build --verbose --forceEnsure --platform windows

Output:

C:\Users\Renan\Desktop\pawn-request>sampctl p build --verbose --forceEnsure --platform windows
INFO: Southclaws/pawn-requests:0.8.7 read package from directory C:\Users\Renan\Desktop\pawn-request
INFO: Southclaws/pawn-requests:0.8.7 building dependency tree and ensuring cached copies
INFO: |- Southclaws/pawn-requests:0.8.7 is parent
INFO: |- iterating 2 dependencies of Southclaws/pawn-requests:0.8.7
INFO: |-|- github.com/Southclaws/samp-stdlib ensured
INFO: |-|- iterating 1 dependencies of sampctl/samp-stdlib
INFO: |-|-|- github.com/sampctl/pawn-stdlib ensured
INFO: |-|-|- iterating 0 dependencies of sampctl/pawn-stdlib
INFO: |-|- github.com/pawn-lang/YSI-Includes ensured
INFO: |-|- iterating 2 dependencies of pawn-lang/YSI-Includes
INFO: |-|- already visited github.com/sampctl/samp-stdlib
INFO: |-|-|- github.com/Zeex/amx_assembly ensured
INFO: |-|-|- iterating 0 dependencies of Zeex/amx_assembly
INFO: Southclaws/pawn-requests:0.8.7 flattened dependencies to 4 leaves
INFO: github.com/Southclaws/samp-stdlib package already exists at c4b675922ed366549538e3b902d635e6c0992344 refs/heads/master
INFO: github.com/Southclaws/samp-stdlib updating dependency package
INFO: github.com/Southclaws/samp-stdlib updating repository state with <nil> authentication method
INFO: github.com/Southclaws/samp-stdlib performing forced pull to latest tip
INFO: github.com/Southclaws/samp-stdlib ensuring dependency package from cache to C:\Users\Renan\Desktop\pawn-request\dependencies\samp-stdlib force update: true
INFO: pulling latest copy to C:\Users\Renan\.samp\packages\Southclaws\samp-stdlib\default with &{  false 1000 <nil> 0 <nil>}
INFO: pulling latest copy to C:\Users\Renan\Desktop\pawn-request\dependencies\samp-stdlib with &{  false 1000 <nil> 0 <nil>}
INFO: github.com/Southclaws/samp-stdlib package does not have version constraint pulling latest
INFO: Southclaws/pawn-requests:0.8.7 successfully ensured dependency files for github.com/Southclaws/samp-stdlib
INFO: github.com/sampctl/pawn-stdlib package already exists at bcd6dd481b825def41226619551489a3f4f15cb3 refs/heads/master
INFO: github.com/sampctl/pawn-stdlib updating dependency package
INFO: github.com/sampctl/pawn-stdlib updating repository state with <nil> authentication method
INFO: github.com/sampctl/pawn-stdlib performing forced pull to latest tip
INFO: github.com/sampctl/pawn-stdlib ensuring dependency package from cache to C:\Users\Renan\Desktop\pawn-request\dependencies\pawn-stdlib force update: true
INFO: pulling latest copy to C:\Users\Renan\.samp\packages\sampctl\pawn-stdlib\default with &{  false 1000 <nil> 0 <nil>}
INFO: pulling latest copy to C:\Users\Renan\Desktop\pawn-request\dependencies\pawn-stdlib with &{  false 1000 <nil> 0 <nil>}
INFO: github.com/sampctl/pawn-stdlib package does not have version constraint pulling latest
INFO: Southclaws/pawn-requests:0.8.7 successfully ensured dependency files for github.com/sampctl/pawn-stdlib
INFO: github.com/pawn-lang/YSI-Includes package already exists at 1c9d229336eb4c0944fcc0fed0002ce5eb9595f3 refs/heads/4.x
INFO: github.com/pawn-lang/YSI-Includes updating dependency package
INFO: github.com/pawn-lang/YSI-Includes updating repository state with <nil> authentication method
INFO: github.com/pawn-lang/YSI-Includes performing forced pull to latest tip
INFO: github.com/pawn-lang/YSI-Includes ensuring dependency package from cache to C:\Users\Renan\Desktop\pawn-request\dependencies\YSI-Includes force update: true
INFO: pulling latest copy to C:\Users\Renan\.samp\packages\pawn-lang\YSI-Includes\default with &{  false 1000 <nil> 0 <nil>}
INFO: pulling latest copy to C:\Users\Renan\Desktop\pawn-request\dependencies\YSI-Includes with &{  false 1000 <nil> 0 <nil>}
INFO: github.com/pawn-lang/YSI-Includes package does not have version constraint pulling latest
INFO: Southclaws/pawn-requests:0.8.7 successfully ensured dependency files for github.com/pawn-lang/YSI-Includes
INFO: github.com/Zeex/amx_assembly package already exists at 850434c1df4793acf5a484c9f3670c37dc5997ab refs/heads/master
INFO: github.com/Zeex/amx_assembly updating dependency package
INFO: github.com/Zeex/amx_assembly updating repository state with <nil> authentication method
INFO: github.com/Zeex/amx_assembly performing forced pull to latest tip
INFO: github.com/Zeex/amx_assembly ensuring dependency package from cache to C:\Users\Renan\Desktop\pawn-request\dependencies\amx_assembly force update: true
INFO: pulling latest copy to C:\Users\Renan\.samp\packages\Zeex\amx_assembly\default with &{  false 1000 <nil> 0 <nil>}
INFO: pulling latest copy to C:\Users\Renan\Desktop\pawn-request\dependencies\amx_assembly with &{  false 1000 <nil> 0 <nil>}
INFO: github.com/Zeex/amx_assembly package does not have version constraint pulling latest
INFO: Southclaws/pawn-requests:0.8.7 successfully ensured dependency files for github.com/Zeex/amx_assembly
INFO: Checking for cached package pawn-v3.10.4-windows.zip in C:\Users\Renan\.samp
INFO: Using cached package pawn-v3.10.4-windows.zip
INFO: using include path C:\Users\Renan\Desktop\pawn-request\dependencies\samp-stdlib
INFO: using include path C:\Users\Renan\Desktop\pawn-request\dependencies\pawn-stdlib
INFO: using include path C:\Users\Renan\Desktop\pawn-request\dependencies\YSI-Includes
INFO: using include path C:\Users\Renan\Desktop\pawn-request\dependencies\amx_assembly
INFO: building Southclaws/pawn-requests:0.8.7 with 3.10.4
INFO: executing compiler in C:\Users\Renan\Desktop\pawn-request as [LD_LIBRARY_PATH=C:\Users\Renan\.samp\pawn\3.10.4 DYLD_LIBRARY_PATH=C:\Users\Renan\.samp\pawn\3.10.4] [C:\Users\Renan\.samp\pawn\3.10
.4\pawncc.exe C:\Users\Renan\Desktop\pawn-request\test.pwn -DC:\Users\Renan\Desktop\pawn-request -oC:\Users\Renan\Desktop\pawn-request\test\gamemodes\test.amx -d3 -;+ -(+ -\+ -Z+ -iC:\Users\Renan\Desk
top\pawn-request\dependencies\samp-stdlib -iC:\Users\Renan\Desktop\pawn-request\dependencies\pawn-stdlib -iC:\Users\Renan\Desktop\pawn-request\dependencies\YSI-Includes -iC:\Users\Renan\Desktop\pawn-r
equest\dependencies\amx_assembly]
failed to compile package entry: exit status 3221226505

Compiler command arguments

INFO: executing compiler in 

C:\Users\Renan\Desktop\pawn-request

as 
[
LD_LIBRARY_PATH=C:\Users\Renan\.samp\pawn\3.10.4
DYLD_LIBRARY_PATH=C:\Users\Renan\.samp\pawn\3.10.4
]
[
C:\Users\Renan\.samp\pawn\3.10.4\pawncc.exe
C:\Users\Renan\Desktop\pawn-request\test.pwn
-DC:\Users\Renan\Desktop\pawn-request
-oC:\Users\Renan\Desktop\pawn-request\test\gamemodes\test.amx
-d3 -;+ -(+ -\+ -Z+
-iC:\Users\Renan\Desktop\pawn-request\dependencies\samp-stdlib
-iC:\Users\Renan\Desktop\pawn-request\dependencies\pawn-stdlib
-iC:\Users\Renan\Desktop\pawn-request\dependencies\YSI-Includes
-iC:\Users\Renan\Desktop\pawn-request\dependencies\amx_assembly
]
failed to compile package entry: exit status 3221226505

JsonGetObject always failed "failed to parse response as JSON: ''"

my json file:

{
    "user1": {
        "name": "mahesh",
        "password": "password1",
        "profession": "teacher",
        "id": 1
    }
}

and my code:

   RequestJSON(
        client,
        "test",
        HTTP_METHOD_GET,
        "OnGetJson",
        .headers = RequestHeaders()
    );

forward OnGetJson(Request:id, E_HTTP_STATUS:status, Node:node);
public OnGetJson(Request:id, E_HTTP_STATUS:status, Node:node) {
    new Node:output;
    JsonGetObject(node, "user1", output);
}

Plugin Error

I am using http://host.csworld.ge Host and i have this error when loading plugin
Failed (/lib32/libc.so.6: version `GLIBC_2.33' not found (required by plugins/requests.so))

Depending the order, some itens in the RequestJSON wont go to the output.

I was using an API (https://ipinfo.io/) to check if the players IP were vpn/proxy, and so some other things with it. The problem is, if i do the callback on a certain way to retrieve the data, it does not work anymore. Changing the order wont resolve it and etc.

If i do the "privacy" object in the bottom, it wont work, and the "ret" error will be 1.
I was doing the test aswell in a weather api (https://openweathermap.org/api) and occurs the same thing.

My code:

CheckISP(playerid) // this is called in OnPlayerConnect
{
    new playerIP[16];
    GetPlayerIp(playerid, playerIP, sizeof(playerIP));

    client = RequestsClient("https://ipinfo.io/");

    new format_antivpn[250];
    format(format_antivpn, sizeof(format_antivpn), "64.145.93.228?token=MY_TOKEN"); // 37.120.244.100
    // custom IPS with vpn = true;

    RequestJSON(
		client,
		format_antivpn,
		HTTP_METHOD_GET,
		"OnGetAntiVPN"
	);

    targetPLAYER = playerid;
}

forward OnGetAntiVPN(Request:id, E_HTTP_STATUS:status, Node:node);
public OnGetAntiVPN(Request:id, E_HTTP_STATUS:status, Node:node)
{
    switch(status){
        case HTTP_STATUS_OK:{
            new Node:asn, Node:org, Node:privacy;

            new playerid = targetPLAYER;

            JsonGetObject(node, "privacy", privacy);
            JsonGetBool(privacy, "vpn", User[playerid][VPN]);
            JsonGetBool(privacy, "proxy", User[playerid][Proxy]);

            JsonGetString(node, "city", User[playerid][City]);
            JsonGetString(node, "country", User[playerid][Country]);
            JsonGetString(node, "timezone", User[playerid][TimeZone]);
            JsonGetString(node, "postal", User[playerid][Zip]);
            
            JsonGetObject(node, "asn", asn);
            JsonGetString(asn, "name", User[playerid][Isp]);

            JsonGetObject(node, "company", org);
            JsonGetString(org, "name", User[playerid][Org]);
        
            printf("vpn %s", User[playerid][VPN] ? "true" : "false");
            printf("proxy %s", User[playerid][Proxy] ? "true" : "false");

            printf("city %s", User[playerid][City]);
            printf("country %s", User[playerid][Country]);
            printf("timezone %s", User[playerid][TimeZone]);
            printf("postal %s", User[playerid][Zip]);
            printf("isp %s", User[playerid][Isp]);
            printf("org %s", User[playerid][Org]);
        }
        default: printf("%s", E_HTTP:STATUS:status);
    }
    return 1;
}

JSON parse error on Status 204

If a xyz API response with no content Status Code 204 the library gives error of ERROR: failed to parse response as JSON

Server Crash on error occured - OnRequestFailure callback issue

Hello everybody, so i was trying to Send some kind of JSON Data to my website but unfortunatly it was facing some techincal issues so that it resulted in 500 ERROR and then my server crashed with the following Crash logs:

[29/05/2018 | 17:02:33] [debug] Server crashed due to an unknown error
[29/05/2018 | 17:02:34] [debug] Native backtrace:
[29/05/2018 | 17:02:34] [debug] #0 6c89d48c in ?? () from cpprest_2_10.dll
[29/05/2018 | 17:02:34] [debug] #1 6ca09ee0 in ?? () from plugins\requests.DLL
[29/05/2018 | 17:02:34] [debug] #2 6ca0a1d9 in ?? () from plugins\requests.DLL
[29/05/2018 | 17:02:34] [debug] #3 6ca06d15 in ?? () from plugins\requests.DLL
[29/05/2018 | 17:02:34] [debug] #4 6ca05416 in ?? () from plugins\requests.DLL
[29/05/2018 | 17:02:34] [debug] #5 6ccb62e4 in ?? () from C:\Windows\system32\ucrtbase.DLL
[29/05/2018 | 17:02:34] [debug] #6 76baefac in ?? () from C:\Windows\system32\kernel32.dll
[29/05/2018 | 17:02:34] [debug] #7 76fb3628 in ?? () from C:\Windows\SYSTEM32\ntdll.dll
[29/05/2018 | 17:02:34] [debug] #8 76fb35fb in ?? () from C:\Windows\SYSTEM32\ntdll.dll
[29/05/2018 | 17:02:34] [debug] Registers:
[29/05/2018 | 17:02:34] [debug] EAX: 00000000 EBX: 0863c4d0 ECX: a30e6070 EDX: 083ae728
[29/05/2018 | 17:02:34] [debug] ESI: 0863c4d0 EDI: 002d73e8 EBP: 09d2ffec ESP: 09d2ffdc
[29/05/2018 | 17:02:34] [debug] EIP: 76fb35fb EFLAGS: 00010206
[29/05/2018 | 17:02:34] [debug] Stack:
[29/05/2018 | 17:02:34] [debug] ESP+00000000: 6ccb6290 086bccd8 00000000 00000000

and i have already used the OnRequestFailure Callback and the callback of the RequestJSON Function (the 4th argument)

forward OnFinishDSRequest(Request:id, E_HTTP_STATUS:status, Node:node); // the the 4th argument of the RequestJSON Function...
public OnFinishDSRequest(Request:id, E_HTTP_STATUS:status, Node:node) {
    if(id == DS_JSON && _:node != -1)
    {
       new logs[650], Contentlen[600]; JsonStringify(node, Contentlen);
       switch(status)
       {
          case 200,201,202,204: {
             format(logs, sizeof(logs), "TCP Request sent successfully, sent JSON Node Preview: %s\r\n", Contentlen);
          }
          default: {
             format(logs, sizeof(logs), "The server returned an error while fetching the requested data: ERROR %d", _:status);
          }
	   }
         // some action
    }
    return 1;
}
public OnRequestFailure(Request:id, errorCode, errorMessage[], len)
{
   new logs[350];
   if(id == DS_JSON)
   {
      format(logs, sizeof(logs), "The server returned an error while fetching the requested data: %s(ERROR %d)", errorMessage, errorCode);
      // some action
   }
   return 1;
}

server crashed

exemple:
new WebSocket: ws = WebSocketClient("ws://56.45.678.65:46657/websocket", "test");
WebSocketSend(ws, "hello server");

server_ log: [06:11:30] ERROR: WebSocketClient failed: set_fail_handler: 9: Timer Expired
server shutdown

Invalid Generated JSON Node

Hello everybody, so i am trying to send some generate some kind of JSON Node which will be used to send a messages to my discord server from my sa-mp server.... using Webhooks, but on debugging the code i found that my generated JSON Node is invalid and isn't completed

Expected Output:

{ "main": { "channel_id": "4185399019241555500", "webhook_authtoken": "35JHEf2f5UOyM0-GoxdRKT_GT3NsAfbc1Y4YUSnEj3WvSvfrfdcvEF7cFC-Ow2kdI00p5h", "bot_username": "[BR]Moderator", "bot_avatar": "https:\/\/cdn.discordapp.com\/avatars\/37227669fff763727872\/b0a36c0f6e5ffff86c00a45b4cba8f71f.webp?size=128", "tts": "False" }, "general": { "description": "Testoretoz", "title": "Test...", "color": "#ad4b09", "thumbnail": "https:\/\/encrypted-tbn0.gstatic.com\/images?q=tbn:ANd9GcQGmnrRD-rcF8bojIG4C-ZrDPqoR6EWJ630cLZdg-bmJJk5NwgjeQ", "image": "https:\/\/png.icons8.com\/ios\/1600\/discord-logo.png", "message": "Hello, world! :alien:\ud83d\udc99", "timestamp": "default" }, "author": { "name": "[BR]John_Magdy", "url": "https:\/\/www.facebook.com\/zoro", "avatar_url": "https:\/\/graph.facebook.com\/17895065gtrfg4113\/picture?type=small" }, "footer": { "text": "Hello footer", "image_url": "https:\/\/vignette.wikia.nocookie.net\/theamazingworldofgumball\/images\/a\/af\/Discord_Logo.png\/revision\/latest?cb=20170105233205" }, "fields": [ { "name": "Field Name #1", "value": "Field Value #1", "inline": true }, { "name": "Field Name #2", "value": "Field Value #2", "inline": true }, { "name": "Field Name #3", "value": "Field Value #3", "inline": true }, { "name": "Field Name #4", "value": "Field Value #4", "inline": true } ] }

Output:

{"author":{"avatar_url":"i.imgur.com/I9tPe17.jpg","name":"BrownTurbo Gaming","url":"my-domain.ovh"},"fields":{"9=AEIGH":{"inline":true,"name":"BOT systems Status","value":"BOT"},"AEIGH":{"inline":true,"name":"User Roles","value":"@BOT"},"IGH":{"inline":true,"name":"Nickname","value":"N/A"}},"footer":{"text":"GuildUser Statistics"},"general":{"color":"#ad4b09","timestamp":"default","title":"***BrownTurbo Gaming***'s GuildUser Status"},"main":{"bot_avatar":"cdn.discordapp.com/avatars/372276696763efd2/b0a36c0ewfded186c00a45b4cba8f71f.webp?size=128","bot_username":"[BR]Moderator","channel_id":-

the problem is the Node isn't completed (that's not my full columns) and this - in channel_id row and the sort of the Columns isn't correct it must be sorted like that Expected Output which starts with channel_id which makes my target PHP Script output alot of errors and then it results in:

The server returned an error while fetching the requested data: ERROR -1
ERROR: failed to parse response as JSON: ..........

My JsonObject Code: https://pastebin.com/8hYRqgCc

libc.so.6: version `GLIBC_2.33' not found

So I've read #50 and #49

I'm running a fresh build of Debian 11 Bullseye. I don't have version 2.33 or 3.4.29 of GLIBC.

Now I'm guessing if I compile it myself maybe it will use the latest version. But just running task just leads me to other errors.

task: [default] cmake .. -DCMAKE_BUILD_TYPE=Debug
CMake Error at CMakeLists.txt:1 (include):
  include could not find load file:

    /root/plugins/pawn-requests-0.10.0/conanbuildinfo.cmake


CMake Error at CMakeLists.txt:2 (conan_basic_setup):
  Unknown CMake command "conan_basic_setup".


CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 3.18)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!

I installed Conan via python3 -m pip install conan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.