Skip to content
⌘ NSIS Forum Archive

NSISdl doesn't work in compiled version

15 posts

ArtUrlWWW#

NSISdl doesn't work in compiled version

Hello.

I've compiled NSIS with commands

scons SKIPUTILS="NSIS Menu"
scons PREFIX="C:\temp\NSIS" install
and when I runned compiled version of the NSIS with script


Section "Download Updater"
CreateDirectory $INSTDIR

StrCpy $2 "$INSTDIR\currentLauncherURL.dat"

NSISdl::download http://files.lifesim******builds/stable/Windows_x32/currentLauncherURL.txt $2
Pop $0
StrCmp $0 success success
SetDetailsView show
DetailPrint "download failed: $0"
MessageBox MB_OK "Download failed: $0"
Abort
success:
FileOpen $4 $2 r
FileRead $4 $5 ; we read until the end of line (including carriage return and new line) and save it to $1
FileClose $4 ; and close the file

StrCpy $2 "$INSTDIR\LifeSimLauncher.exe"
NSISdl::download $5 $2
Pop $0
StrCmp $0 success success2
SetDetailsView show
DetailPrint "download failed: $0"
MessageBox MB_OK "Download failed: $0"
Abort
success2:
; Exec '"$2"'
Quit


SectionEnd
It's fails with error
---------------------------
LifeSim - Life Simulator Game Setup
---------------------------
Download failed: connecting to host
---------------------------
ОК
---------------------------

But this script works correctly with precompiled version, that I downloaded from NSIS sf website.

I tried source from https://sourceforge.net/p/nsis/code/...S/tags/v30rc2/ and from https://sourceforge.net/p/nsis/code/...ee/NSIS/trunk/ .

Why it doesn't work in version, that compiled from sources?

Thank you!
Anders#
Compiler version?

Try adding some calls to OutputDebugString in connection.cpp and run in it in a debugger so you can find the reason why connect() fails...
ArtUrlWWW#
Using Microsoft tools configuration (14.0).
I use MS VS 2015.
But I can't understand, how to debug it?.. There are no *.sln solutions for MS VS, and project compiled with (through) Python script - so weird... Why you use third-party scripts and python, but you do not include *.sln files for the project? It can be useful for Windows users.
Anders#
We use Scons to build because it supports Windows and posix. We also (try to) support every version of VS from 6 to 2015 but there are no VS project files.

You can also use DebugView from Sysinternals to view OutputDebugString messages if you cannot figure out how to run a .exe in the debugger...
ArtUrlWWW#
OK, may be you can recommend versions of the MS VS, that are 100% tested? ) May be MS VS 2013?
ArtUrlWWW#
I found http://stackoverflow.com/questions/1...-visual-studio , but how to add breakpoints, if it's only exe, that not "linked" with the project and code? 🙂 I am sorry for this silly question.
Anders#
If you don't know how to code, why do you need to recompile? Add a MessageBox in the .nsi before the plugin call. Add "DebugBreak();" in the plugin code, compile and then attach to the running exe...
ArtUrlWWW#
I am newbie in C++ and also in such build systems, like in NSIS ).
I can't find any examples for DebugBreak for using in NSIS code. Why to use MessageBox in nsi? What will it show? May be some message from DebugBreak, that pop'ed from plugin?

I guess, that problem is in Contrib/NSISdl/connection.cpp, at the line 142, or at the line 169...
ArtUrlWWW#
I checked it twice - error occurred on line 142 - I changed m_errorstr to "connecting to host number 1" and now compiled installer shows "connecting to host number 1", when I runned it.
Anders#
After line 142, add something like this:

char dbg[99];
wsprintfA(dbg, "winsock error: %d", ERRNO);
MessageBoxA(0, dbg, 0, 0);
and you should then be able to lookup which WSAE* value is reported as the cause.
ArtUrlWWW#
Ohhh, thank you, Anders! I Googled such code, but not found it. As result, compiled installer shows error
---------------------------
Ошибка
---------------------------
winsock error: 10035
---------------------------
ОК
---------------------------

That means (from https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx )

WSAEWOULDBLOCK
10035
Resource temporarily unavailable.
This error is returned from operations on nonblocking sockets that cannot be completed immediately, for example recv when no data is queued to be read from the socket. It is a nonfatal error, and the operation should be retried later. It is normal for WSAEWOULDBLOCK to be reported as the result from calling connect on a nonblocking SOCK_STREAM socket, since some time must elapse for the connection to be established.

Why and how to fix that?

Thank you!
Anders#
You could try changing line 140 to
else if (ERRNO!=EINPROGRESS && ERRNO!=EWOULDBLOCK)
Not really sure why VS2015 would trigger this, maybe it generates slightly different code causing a tiny timing change.
ArtUrlWWW#
I tried that and now I got another message - error="download incomplete"; from nsisdl.cpp, line 434.
ArtUrlWWW#
Have you installed MS VS 2015? If no, I can provide you TeamViewer access to my PC, if you have some time to check that bug.