Results 1 to 5 of 5

Thread: [RESOLVED] Internal Server Error

  1. #1

    Thread Starter
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,524

    Resolved [RESOLVED] Internal Server Error

    I'm writing a webservice, but despite simplifying the app as much as i can, it always returns Internal Server Error.
    I know the problem must be either in the asmx...

    Code:
    Imports System.Web.Services
    Imports System.Web.Services.Protocols
    Imports System.ComponentModel
    Imports System.Web.Script.Services
    
    ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    <System.Web.Script.Services.ScriptService()>
    <System.Web.Services.WebService(Namespace:="http://www.scProject.biz")>
    <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
    <ToolboxItem(False)>
    Public Class ASP_triQuiz_Service3
        Inherits System.Web.Services.WebService
    
        Dim game As Hangman_Game
    
        <WebMethod()>
        Public Function CreateNewGame() As String
    
            game = New Hangman_Game
    
            Dim thread As New Threading.Thread(AddressOf DoWork, 20971520)
            thread.IsBackground = True
            thread.Start()
            thread.Join()
    
            While Not game.gameReady
                ' do nothing
                Threading.Thread.SpinWait(100)
            End While
    
    
            Return getArrayString(game.gameGridValues)
    
        End Function
    
        <WebMethod()>
        Public Function SayHi() As String
            Return "hi!"
        End Function
    
        Private Sub DoWork()
            'Stop
            While Not game.created
                ' do nothing
                Threading.Thread.SpinWait(100)
            End While
            game.createNew2()
        End Sub
    
        Private Function getArrayString(GridValues()() As String) As String
            Dim returnString As String = ""
    
            For y As Integer = 0 To 24
                returnString &= String.Join(",", GridValues(y)) & Environment.NewLine
            Next
    
            Return returnString.TrimEnd(CChar(vbCr), CChar(vbLf))
    
        End Function
    
    End Class
    Or the error could be in the ajax call...

    Code:
    function newGame( ){
        alert('newGame()');     
       // Validating input
         $.ajax({
            type: 'POST',
            url: 'http://www.scProject.biz/ASP_triQuiz_Service3.asmx/CreateNewGame',
            data: '{}', 
            dataType: 'text',
            success: function( response ) {
              alert('success ' + response);
            },
            error: function( e ) { 
              alert('error calling service ' + e.statusText); 
            }
         });
      }
    Can anyone spot the error?

  2. #2
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,551

    Re: Internal Server Error

    It is really unusual to have a webmethod that is manually messing around with threads like that, the client is still going to block regardless of what is going on at the server side. I would personally look at creating an Async webmethod rather than trying to handle threading directly. Not sure if that is the cause of the crash or not, but it is a layer of complexity you could probably avoid.

    There could be an error in the call to game.createNew2() but without seeing the code I couldn't say.

    It might help if you added some diagnostic logging the the server, that way at least you could see what is happening.

  3. #3
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,621

    Re: Internal Server Error

    You might have a CORS issue.
    Check this (ignore and FOR THE LOVE OF GOD do not use WCF!)
    https://www.vbforums.com/showthread....d-CORS-enabled
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  4. #4

    Thread Starter
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,524

    Re: Internal Server Error

    Quote Originally Posted by PlausiblyDamp View Post
    It is really unusual to have a webmethod that is manually messing around with threads like that, the client is still going to block regardless of what is going on at the server side. I would personally look at creating an Async webmethod rather than trying to handle threading directly. Not sure if that is the cause of the crash or not, but it is a layer of complexity you could probably avoid.

    There could be an error in the call to game.createNew2() but without seeing the code I couldn't say.

    It might help if you added some diagnostic logging the the server, that way at least you could see what is happening.
    The only point of the threading is to allocate more memory to what can be a recursive function. I do know the game core and the threading works in a desktop app and in an asp.net web application, on the same server...

  5. #5

    Thread Starter
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,524

    Re: Internal Server Error

    I got it working eventually. The biggest problem was underscore characters in the service name. Once I’d figured it must be that, it was straightforward from then…

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width