-
Nov 6th, 2023, 03:44 AM
#1
[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?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Nov 6th, 2023, 06:02 AM
#2
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.
-
Nov 6th, 2023, 10:29 AM
#3
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
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Nov 6th, 2023, 09:33 PM
#4
Re: Internal Server Error
Originally Posted by PlausiblyDamp
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...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Nov 7th, 2023, 04:18 AM
#5
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…
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|