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

Stored Procedure Not Working #12

Closed
mtallenca opened this issue May 3, 2019 · 7 comments
Closed

Stored Procedure Not Working #12

mtallenca opened this issue May 3, 2019 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@mtallenca
Copy link

I'm connecting to a AWS Aurora DB. Simple queries work fine. I've not been able to get a stored procedure call to work.

I've created your test case procedure p ( select a * b) and i'm attempting to call it. I'm receiving the following:

[WARNING] MySqlConnection: Ignoring error because no response NoSuchMethodError: The method 'processResponse' was called on null.
Receiver: null
Tried calling: processResponse(Instance of 'Buffer') #0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
#1 ReqRespConnection._handleData (package:mysql1/src/single_connection.dart:329:31)

#2 ReqRespConnection._handleHeader (package:mysql1/src/single_connection.dart:298:13)

#3 ReqRespConnection._readPacket (package:mysql1/src/single_connection.dart:283:7)

#4 MySqlConnection.connect. (package:mysql1/src/single_connection.dart:120:13)
#5 BufferedSocket._onData (package:mysql1/src/buffered_socket.dart:93:11)
#6 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#7 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#8 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#9 _SyncStreamController._sendData (dart:async/stream_controller.dart:764:19)
#10 _StreamController._add (dart:async/stream_controller.dart:640:7)
#11 _StreamController.add (dart:async/stream_controller.dart:586:5)
#12 new _RawSocket. (dart:io/runtime/binsocket_patch.dart:1323:33)
#13 _NativeSocket.issueReadEvent.issue (dart:io/runtime/binsocket_patch.dart:844:14)
#14 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#15 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#16 _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#17 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)

@mtallenca
Copy link
Author

I do receive the result - however the trace happens and the connection is closed.

@adamlofts
Copy link
Owner

The proc branch here might work better for you https://github.com/adamlofts/mysql1_dart/tree/proc
Let me know if it helps and I'll merge to master if so.

@virtz
Copy link

virtz commented May 21, 2019

i have a similar issue. I keep getting 'Bad state: Cannot write to socket, it is closed'

@mtallenca
Copy link
Author

mtallenca commented May 21, 2019

When calling a stored procedure - the MySQL Protocol has the server sending an additional packet to the client that is not handled by the current dart driver. The current driver throws an exception because no handler is defined for the last packet (non data packet) and closes the socket. Subsequent calls on the same connection will give you the "Bad state: Cannot write to socket, it is closed"

A quick work around until the protocol is handled correctly is to add the following in single_connection.dart

Future _handleData(Buffer buffer) async {
// at the top of the function
if (_handler == null) {
_log.fine("Packet read - but no handler assigned...");
return;
}

In my case - we have decided not to implement a dart server connecting to MySQL because this driver is not yet complete. It works great for simple queries, but I'm not able to count on this yet in a production environment.

@virtz
Copy link

virtz commented May 22, 2019

Thank you very much. I'll try it. I couldn't find a driver for MS SQL for flutter, that's why I think I'm stuck with this.

@adamlofts
Copy link
Owner

@virtz Did you try the proc branch I mentioned above?

@virtz
Copy link

virtz commented May 26, 2019

no, sorry I'm new to github. Do you mind telling how to try it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants