Error 502: Bad Gateway

  • Hi,

    I am calling 2008 database from a web service and getting this "Bad Gateway" error...

    Here are some details:

    - Depending on which way Web service calls sql, it sometimes returns "500 - Internal Server Error" instead

    - Returns one of those errors 99% of the times and in one environment only, all other environments are fine. The datasets in all env's are the same

    - In sql, I was able to locate a line of code that seems to cause this problem, as soon as I comment that line everything works fine

    - This line adds a condition in WHERE saying something like ...AND Filed1 LIKE '%condition%', where Field1 is a varchar(500)

    - I realize that it's probably not a best idea to use a large varchar field in where and with LIKE, but that's the way web service does it.

    - The error does not occur if I change the sql to return, say, TOP 100 ("normally" it goes through like 300000 recs returning about 2000)

    So it seems to be very much like... Timeout at server? Network? Any ideas/suggestions?

    Thank you

  • Changing WHERE from "...Field1 LIKE '%condition%'..."

    to "...LEFT(Field1, 500) LIKE '%condition%'..."

    seems to resolve it. WHY?))))

  • If you run the query in SSMS what's the error you get?

  • There are no errors in SSMS

  • Well that's not terribly useful then, is it. There must be something that the app is doing differently than when you are calling it through SSMS. If possible I would get a SQL trace of this happening so you can get the exact error. If the query is the same there may be a connection setting that's causing the error or a timeout if the query is running for a long time. It wouldn't surprise me if that LIKE was causing a problem but it sounds like there isn't much you can do about it.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply