nginx for Windows - WSASend() socket error 10057

Sergey Brester serg.brester at sebres.de
Wed Feb 12 12:38:13 UTC 2020


 

It looks like your service defined in auth_http doesn't answer (or no
listener on 127.0.0.1 port 9000?)... 

try netstat (in cmd as admin): 

netstat /nabo
netstat /nabo | grep -A 1 ":9000b" 

and check whether the listener on port 9000 is bound to 127.0.0.1 (or it
is 0.0.0.0 only?) and it is the process you expect to see there (can be
"reserved" by some other windows-service). 

additionally try to telnet or curl it: 

curl -H "Auth-Method: plain" -H "Auth-User: user" -H "Auth-Pass: pwd" -H
"Auth-Protocol: imap" -H "Auth-Login-Attempt: 1" -i
http://127.0.0.1:9000/cgi-bin/nginxauth.cgi 

if it does not answer, make another attempt by replace 127.0.0.1 with
0.0.0.0 (or a host-name). 

If it answers - see whether it is the expected response (some examples
of good and bad responses are described in
http://nginx.org/en/docs/mail/ngx_mail_auth_http_module.html [7]). 

But I guess if WSASend fails, it would probably (unexpected) reject the
connection during the send (or even connect) process.
It can be also invalid (unexpected) content-length in keep-alive connect
to auth-upstream - so send but still receive is expected (or vice
versa). 

Also follow this forum topic addressing similar issue:
https://forum.nginx.org/read.php?2,257206,257207#msg-257207 [8] 

Anyway it doesn't look to me like an issue of nginx (regardless windows
or not), but you can also try some other ready build (for example on my
GH [9] - nginx.zip [10], where it works well). 

Regards,
Sergey 

12.02.2020 03:01, Yury Shpakov wrote: 

> Hi there, 
> 
> Trying to make nginx work as SMTP server and/or SMTP proxy. Done everything according to: 
> http://nginx.org/en/docs/howto_build_on_win32.html [2] 
> 
> But excluded (don't care about SSL at this point so don't want to install/configure Perl now): 
> --with-openssl=objs/lib/openssl-master 
> 
> --with-openssl-opt=no-asm 
> --with-http_ssl_module 
> And added: 
> --with-mail
> 
> nmake was successful and nginx.exe was created. 
> 
> However nginx.exe keeps failing with the error: 
> WSASend() failed (10057: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied) while in http auth state, client: 127.0.0.1, server: 0.0.0.0:8025 
> 
> Windows API says the following about this error: 
> 
> WSAENOTCONN10057
> Socket is not connected.A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using SENDTO [3]) no address was supplied. Any other type of operation might also return this error--for example, SETSOCKOPT [4] setting SO_KEEPALIVE [5] if the connection has been reset.
> 
> https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2 [6]
> 
> Windows Sockets Error Codes (Winsock2.h) - Win32 apps | Microsoft Docs [6] 
> Return code/value Description; WSA_INVALID_HANDLE 6: Specified event object handle is invalid. An application attempts to use an event object, but the specified handle is not valid. 
> docs.microsoft.com 
> 
> Managed to debug your code in VS 2010 a little bit but it's brutal C so it's hard to figure your code out. And this debugger doesn't show you any local variables values. 
> 
> Any recommendation for me to make it work? 
> 
> Tried to play with config (commenting/uncommenting): 
> 
> #user nobody; 
> worker_processes 1; 
> 
> #error_log logs/error.log; 
> #error_log logs/error.log notice; 
> #error_log logs/error.log info; 
> 
> #pid logs/nginx.pid; 
> 
> events { 
> worker_connections 1024; 
> } 
> 
> mail { 
> server_name localhost; 
> auth_http localhost:9000/cgi-bin/nginxauth.cgi; 
> # auth_http none; 
> 
> smtp_auth none; 
> # smtp_auth login plain cram-md5; 
> # smtp_capabilities "SIZE 10485760" ENHANCEDSTATUSCODES 8BITMIME DSN; 
> xclient off; 
> 
> server { 
> listen 8025; 
> protocol smtp; 
> proxy on; 
> proxy_pass_error_message on; 
> } 
> } 
> Tried both under a regular user and under admin. Tried on 25, 1025 and 8025 ports. 
> 
> Thank you, 
> Yury 
> 
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel [1]
 

Links:
------
[1] http://mailman.nginx.org/mailman/listinfo/nginx-devel
[2] http://nginx.org/en/docs/howto_build_on_win32.html
[3]
https://docs.microsoft.com/en-us/windows/desktop/api/winsock/nf-winsock-sendto
[4]
https://docs.microsoft.com/en-us/windows/desktop/api/winsock/nf-winsock-setsockopt
[5]
https://docs.microsoft.com/en-us/windows/desktop/winsock/so-keepalive
[6]
https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
[7] http://nginx.org/en/docs/mail/ngx_mail_auth_http_module.html
[8] https://forum.nginx.org/read.php?2,257206,257207#msg-257207
[9] https://github.com/sebres/nginx/releases/tag/release-1.13.0
[10] https://github.com/sebres/nginx/files/2246440/nginx.zip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20200212/59db787a/attachment.htm>


More information about the nginx-devel mailing list