Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 502 Bad Gateway when I try to query table in SQL Server and server nginx #580

Closed
juanludukeboss opened this issue Oct 2, 2019 · 22 comments
Assignees

Comments

@juanludukeboss
Copy link

Hi,
When I try to query table in SQL Server with the API, always I'm getting error 502 Bad Gateway. The server is ok, because a sample file with PDO connection PHP is working correctly, but the API is not working.
For analyze the problem, I have doing profiling and I'm looking that the server is very slow in the method that get the structure information table and finally return 502 Bad Gateway. I attach capture of profiling.

imagen

@mevdschee
Copy link
Owner

Thank you for filing this issue. It seems the request takes longer than 30 seconds, is that correct?

@mevdschee
Copy link
Owner

Can you tell me how many tables and how many columns you have in your database? The method you see that are slow are analyzing the database structure.

@mevdschee mevdschee self-assigned this Oct 2, 2019
@juanludukeboss
Copy link
Author

Yes, the problem is that database has about 3.000 tables, ¿it is possible that this is the problem?

@mevdschee
Copy link
Owner

Yes it is.. I'm analyzing all the tables and I'm storing the structure in the cache for quick retrieval.

@juanludukeboss
Copy link
Author

It's possible modify anything in the API for just analyze the structure of tables that we are going to work, because for this project only needs 10 tables of this database. But the database complete is about 3.000 tables.

@mevdschee
Copy link
Owner

Currently this is not configurable, but I can make it so that you can.

@juanludukeboss
Copy link
Author

I would appreciate it very much, because I only need to work with 10 tables for this project and I want to use this API, because this API is wonderful and very easy to use

@mevdschee
Copy link
Owner

I've released a new version (v2.6.0).

You can specify the "tables" now in the configuration.

Let me know whether or not it works for you.

@juanludukeboss
Copy link
Author

The new parameter 'tables' in the configuration, Is a array of tables??

@mevdschee
Copy link
Owner

mevdschee commented Oct 2, 2019

Yes, a string representing an array. As the README states it is a "Comma separated list of tables", see:

https://github.com/mevdschee/php-crud-api/blob/master/README.md

Does that work for you?

@juanludukeboss
Copy link
Author

juanludukeboss commented Oct 2, 2019

No, the response return error 500, but the json response is "code" : 9999, very curious.

I Attach capture.
Captura de pantalla 2019-10-02 a las 19 09 02

@mevdschee
Copy link
Owner

Please enable "debug" in the configuration, that may give you some extra information (in the headers).

@juanludukeboss
Copy link
Author

The error is in the line 5526. I attach the capture.

Captura de pantalla 2019-10-02 a las 19 15 53

@mevdschee
Copy link
Owner

mevdschee commented Oct 2, 2019

What request do you do? Are you comparing with a text ntext or image? I can't do what sql server can't do ;-)

@mevdschee
Copy link
Owner

You could try to use "field,sw,value" instead of "field,eq,value" when you are comparing.

@juanludukeboss
Copy link
Author

no, the query is very simple. The filter is in a numeric field. I attach the capture

Captura de pantalla 2019-10-02 a las 19 28 26

@mevdschee
Copy link
Owner

Is the primary key a text, ntext or image?

@mevdschee
Copy link
Owner

Comment out 10585 (Content-Length) and uncomment line 5525. You should see the failing query. This should help you find the cause.

@juanludukeboss
Copy link
Author

Yes, the primary key is varchar type field. I has commented this line and effectively the problem is this. Attach the capture.
What solution can I make here??, because the database is not mine, is a database the my customer and it is in production with other program. :(
Captura de pantalla 2019-10-02 a las 19 44 10

@mevdschee
Copy link
Owner

Did you find the failing SQL query?

@juanludukeboss
Copy link
Author

I think that for this project I will design a simpler API, because there are very few tables and actions that must be performed on this SQL Server database.

Thank you very much for your help.

@mevdschee
Copy link
Owner

Thank you very much for your help.

You are welcome. Good luck with the project and thank you for your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants