Originally Posted by Wims
Hello, your script is almost perfect, you get the /sockread error because /sockread cannot be used outside socket event (mainly on sockread anyway), mIRC will trigger the on sockread event automatically for you based on some rules, all made to make the reading easy.
Remove your timer with /Sockread and put a sockread command inside the event, if you want to read line by line into a %variable, here is what you must do:

on *:SOCKREAD:mysocket: {
if ($sockerr) return
var %read
sockread %read
if ($sockbr == 0) return
;a line is guarantee to be in %read at this point but can be empty line of course.
echo -ag > %read
}

If the last line does not end with a line ending sequence, it won't get caught in this event as it won't be retriggered by mIRC, you can solve this easily by requesting the connection to be close in the header and then handling the on sockclose event for the socket, where you will be guaranteed to have the last line which you must read with var %read | sockread -f %read | echo -ag > %read.

Like this?

Code
alias user {
    var %username = $1
    var %json = $+({ "username": " %username " })
    var %header = POST /user HTTP/1.1 $+ $crlf $+ Host: localhost $+ $crlf $+ Content-Type: application/json $+ $crlf $+ Content-Length: $+ $len(%json) $+ $crlf $+ $crlf
    var %request = %header $+ %json

    echo -a Send request: %request
    sockopen mysocket localhost 3000
    sockmark mysocket %request
}

on *:SOCKOPEN:mysocket: {
    if ($sockerr) return
    sockwrite -nt $sockname $gettok($sock($sockname).mark,1-,$crlf)
}

on *:SOCKREAD:mysocket: {
    if ($sockerr) return
    var %data = $gettok($sock($sockname).mark,1-,$crlf);
    var %dataObj = $json(%data);
    var %username = $1;

    if ($length(%data) > 0) {
        if (%dataObj.success) {
            ; Send data back to IRC
            msg #ScriptTesting Information for user %username: %dataObj.data
        } else {
            ; Show errors in IRC chat
            echo %data
            echo %dataObj
            echo %username
            msg #ScriptTesting An error occurred while retrieving data for user %username: %dataObj.error
        }
        sockclose $sockname
    }
}

Now I don't get any response. No errors, no logs. Only the Send request:
POST /user HTTP/1.1
Host: localhost
Content-Type: application/json
Content-Length:24

{ "username": " test " }