Jump to content

SneakyPeaky99

Members
  • Content Count

    12
  • Joined

  • Last visited

Everything posted by SneakyPeaky99

  1. Hello, I have a problem with TIdTCPConnection.IOHandler.Write() function. I have migrated an application from Delphi 6, and currently I am facing a problem with certain module of this application that is responsible for hosting website. Problem occurs when html parser returns data that should be used to create website (html content). Then this data is passed to IOHandler.Write(). For simplicity, I have swapped actual html code with "0123456789" string (For html content that was passed, this worked the same but I could notice any content created on website because buffer was so big, that will be explained later). After first call of IOHandler.Write() function, everything seems OK, content is displayed on website. After that another call is made and again everything looks OK. And again. But after another call. Last digit is missing, it looks like whenever length is greater than 39, content is not displayed. I have tested it for various data and it looks the same every time. After that IOHandler.Write() function is called again but this time it doesn't add anything to html content. Next call after that is causing application to throw exception: This of course causes application to crash and no more parsing is done. As far as im concerned sending data works but it looks like there is something wrong with size of this thing. This is the code of function in question: procedure TWRStringBuilder.AddStr(const NewStr: string); var tmp_string: String; begin try // Write headers first if not ResponseInfo.HeaderHasBeenWritten then ResponseInfo.WriteHeader; // Don't send block under 500 bytes directly, buffer first if System.Length(NewStr) < 500 then begin inherited AddStr(NewStr); if Length > 2000 then // Send buffers over 2000 bytes only begin tmp_string := '0123456789'; Context.IOHandler.Write(tmp_string); tmp_string := ''; Clear; end; end else // Block over 500 bytes, send current buffer and Str begin //tmp_string := Str; tmp_string := '0123456789'; Context.IOHandler.Write(tmp_string); // Send and flush buffer Clear; //tmp_string := #$D#$A + '<script type="text/javascript">' + #$D#$A + #$D#$A + '</script>' + #$D#$A; Context.IOHandler.Write(tmp_string); // and send current data after that tmp_string := ''; end; except on E: Exception do OnException(E); end; end; Clear procedure only cleans Str variable, it doesn't affect the IOHandler at all. procedure TFMPStringBuilder.Clear; begin FStr := ''; StrSize := 10000; StrPos := 0; SetLength(FStr, StrSize); end; Do you have any idea what could be causing such an error? Thank you very much!
  2. SneakyPeaky99

    IOHandler.Write() problems with SocketError # 10053 exception

    Hello, Sorry for taking so long to respond. In very simple terms, this code should create a web server and then place html content on this web server. Content is dependent on files that are parsed by dws2, said files are located on a harddrive, they include html and script that is executed in brower. Application walkthrough: 1) Set up a web server 2) Wait untill the user refreshes the website. 3) If the website is refreshed then "TWRServer.IdHttpServerCommandGet() is called. This function, among other things, calls ScriptEngine, that parses files from the harddrive. 4) The result of the compilation is returned via the TFMPStringResults class and loaded into a chunk of data to be placed on a website. This chunk is passed to TWRStringBuilder, this class has access to ResponseInfo and Context. Whenever the chunk size of the compiled data reaches a specified size, it is placed on the website. If it doesnt, it is stored in variable that is appended everytime the parser returns more data. As far as I'm aware, the compilatoin is executed once at the beggining of the function, but the process of returning chunks of that compiled data takes place over and over, untill the end of the file. Some time later, after calling the Context.IOHandler.Write() function from InDy, the 100053 exception is thrown. I have spotted an interesting issue. The size of data placed on the website is always equal to 39 characters. After that no more characters are placed on the website, an exception is not thrown after this limit is reached, but rather some time later. When the .WriteHeader function is used (this function is called only once), there's a parameter called ContentLength, that is passed to the InDy TIdIOHandler.Write() function, containing the number 39. This parameter is in some way connected to the limit of characters that are able to be loaded onto the website. When I manually set the ResponseInfo.ContentLength value to 1000, I was able to load 165 characters onto the website until I encountered the following error: Here's the code assigning the ContentLength value: ResponseInfo.ContentLength := 1000; if not ResponseInfo.HeaderHasBeenWritten then ResponseInfo.WriteHeader; If you need any more info, please feel free to let me know.
  3. SneakyPeaky99

    IOHandler.Write() problems with SocketError # 10053 exception

    This is the function that is calling AddStr(). Stringbuilder.AddStr() is calling the function in first question. procedure TFMPStringResult.AddStr(const Str: string); begin Stringbuilder.AddStr(str); inherited AddStr(Str); end; After that inherited AddStr() is called: procedure Tdws2StringResult.AddStr(const Str: string); begin FStr := FStr + Str; debugString('Tdws2StringResult.AddStr: ', FStr); if Assigned(Tdws2StringResultType(ResultType).OnAddString) then Tdws2StringResultType(ResultType).OnAddString(Self, Str) end; Function TFMPStringResult.AddStr() is called from code in dws2.htmlfilter.pas. It doesnt use any .Write() like functions, it just provides fragment of parsed code via the argument of the Stringbuilder.AddStr() function. procedure TSendFunction.Execute; begin Tdws2StringResult(Info.Caller.Result).AddStr(VarToStr(Info['s'])); end; Deeper inside dws2functions.pas. I can paste rest of the call-stack but i don't think it is relevant since it gives good results (i think) and is not related to problem (i think). procedure TInternalFunction.Call(Caller: TProgram; Func: TFuncSymbol); begin FInfo.Caller := Caller; Execute; end;
  4. SneakyPeaky99

    IOHandler.Write() problems with SocketError # 10053 exception

    Back in the days when this program was written function AddStr looked like this but unfortunately .Write() for IdTCPConnection is not available in Indy10, because of that I am using IOHandler directly. Server module code was changed as well because of upgrading to Indy10. This was code that was used a long time ago. I tried to update it and what i came up with is pasted below. Information about running AddStr() method. 1) Server module - line 52 calling IdHTTPServerCommandGet upon OnCommandGet. 2) Body of IdHTTPServerCOmmandGet function: 3) DoGet function of TWRController class: 4) By calling GetResult function, HTML processing is triggered 5) Inside ProcessHTMLForWebServer function: 6) Constructor for script engine with result type class 7) After that ScriptEngine.Execute is called which causes AddStr() to be triggered whenever data is ready. I was facing 10053 error earlier, to solve it i used such function (found it on stackoverflow). It seemed to solve the problem in the short term (because exception is no longer displayed), but this causes ResponseInfo to be null, so meh. I am kind of walking in the dark with this problem and it's hard for me to wrap my head around it. Thank you for your response.
  5. Hello Delphi community, I'm currently facing a challenging issue while debugging a Delphi application that parses HTML, starts up a web server, and hosts a website. Pasting whole parser is impossible but i think that problem lies in RemotingSDK. During the parsing of a specific HTML file, I've encountered the following logs: The relevant part of the code starts at line 135 and involves the usage of the GetCaption function within an HTML template. Here's a snippet of the parsed html code starting from the line 135: <div class="menubutton" title="<%=GetCaption('XMLR_MENU_PREVIEW_LONG')%>"> <% if ReportName <> 'StatusMonitor' then begin Params.SetValues('PrinterFriendly', 'true'); %> <a href="<%=ParamsToLinkString()%>" target="_blank"> <img src="images/header_<%=GetAuthorCompany()%>/header_icon_preview.gif" border="0"><br> <span><!--<%=GetCaption('XMLR_MENU_PREVIEW')%>--></span> </a> <% Params.SetValues('PrinterFriendly', ''); end else begin %> <p> <img src="images/header_<%=GetAuthorCompany()%>/header_icon_preview_gray.gif" border="0"><br> <span><!--<%=GetCaption('XMLR_MENU_PREVIEW')%>--></span> </p> <% end; %> </div> I've narrowed down the issue to a "Software caused connection abort" error, which seems to be related to the Remoting SDK. However, I'm struggling to understand the exact meaning of this error and how to resolve it. Has anyone in the community encountered a similar error before? Any insights, tips, or suggestions on how to approach this debugging challenge would be greatly appreciated. Thank you in advance for your help!
  6. Hello, i am trying to run a program and this type of error is displayed. Can anyone tell me what can i do fix it? I tried: - Process Explorer to find if any dlls are missing (compared to working app installer of this project which is very old) - all good but i dont this program shows all of the dll used by this process. - Dependency Walker - same thing - Looking for this entry in win registry - nothing found - Searching internet - nothing related Below i pasted information where exception is thrown, and some information regarding this problem. Thank you.
  7. SneakyPeaky99

    class EOleSysError with message 'Class not registered'

    Thank you all for your advice. I managed to find the necessary files, after proper registration, the appropriate entries appeared in the registry, and the program started working. Thank you all again for your time, you've been a big help.
  8. SneakyPeaky99

    class EOleSysError with message 'Class not registered'

    I managed to track down what could possibly be those missing .dlls names. Unfortunately I couldn't find them on any machine that this project was running on or was developed or on the internet... I will keep digging to find them. Thank you all for your replies, i will keep you informed with progress.
  9. SneakyPeaky99

    class EOleSysError with message 'Class not registered'

    I run this program on working version of this application, than I have installed all of those dll mentioned in imports section, but the problem didnt disappear. Can you tell me what am i doing wrong? Im not really an expert in this kind of stuff.
  10. SneakyPeaky99

    class EOleSysError with message 'Class not registered'

    The problem is that i dont know what is the name of that DLL.
  11. Hello, I have a problem with debugging program in Delphi. From some time I am bringing back to life a very old project that was initially written in Delphi (around 20 years ago), I updated whole code to be buildable under newest Delphi 11.3. I am using Rad Studio for Delphi 11.3, in project-group there are a couple of separate projects. Some of them are stand-alone modules of this application, and the rest of them are using some other project in this project-group. After some trouble I managed to run debug on most of the projects, but ... and there is a question of this post. Some module can't be debugged, although breakpoints are set in the entry point of the application, debug .dcus are enabled, program throws errors like: Runtime error 204 at 0027BE19 and other error like: Project name.exe raised exception class EIdException with message 'Extension already exists'. Can someone explain to me what should be steps necessary to resolve this types of errors or where should i start looking for solution. It is strange because program does not seem to start (because no breakpoints are hit) but errors are thrown anyway. On top of that sometimes when I try to debug program, IDE annoyingly doesn't hit my breakpoint but instead shows 'CPU' file with assembly code. Can someone tell me how can i get rid of that, I have tried many solution from the internet but non of them solved this problem for me. My last question is the following, nearly all the applications in this project are launched with arguments. Surprisingly after providing arguments with RAD Studio option Run->Parameters some of them are causing strange behaviour. For example after typing '/regserver' as a parameter of the application (which is correct argument for this app) debug doesn't start. IDE seems to be compiling the project but then it doesn't run it. Other parameters are working completely fine. Can someone tell me where should I start digging for information on these topics, or maybe someone has a solution for them.
  12. SneakyPeaky99

    Problems with debugging after migration.

    Thank you for advice, i have managed to determine where was the problem with 'Extension already exists' exception. I have one more question, do you know any way to solve errors like: "Runtime error 204 at 0027BE19"? Or do you know any place i should start looking for solution? Code on the right side is an address code given in hex but it doesn't give me any clue what is going on.
×