Comments (13)
What happens if you run examples/protocol/execute.php? Or try first with $client->ping()
and check if it succeeds.
from client.
Sadly $client->ping() doesn't work too.
PHP
[Tarantool\Client\Exception\RequestFailed]
lid MsgPack - packet body (20)
Tarantool
2019-05-31 11:57:17.550 [1] iproto xrow.c:174 E> ER_INVALID_MSGPACK: Invalid MsgPack - packet body
2019-05-31 11:57:43.571 [1] iproto xrow.c:174 E> ER_INVALID_MSGPACK: Invalid MsgPack - packet body
from client.
Hmm, all client tests pass on all supported Tarantool versions, including the latest 2.2.0: https://travis-ci.org/tarantool-php/client/jobs/539337099#L878. This makes me think that something is misconfigured on your side. Could you show your init lua script or, ideally, provide a full reproducer including a dockerfile (or/and docker-compose), php and lua scripts?
from client.
Not sure if it could help and easy to use, but i've published my docker-compose and all related files to https://github.com/mikkiek/tarantool-php-issue-55
As you can see, i'm using default tarantool 2.2.0, though php-fpm based on default image but has a lot additional modules
from client.
I was able to reproduce the error using your docker-compose. The problem is with the mbstring.func_overload = 2
setting in /usr/local/etc/php/php.ini
. When you disable this line or run your script in cli mode with the -n
flag, everything just works. Note that mbstring function overloading is deprecated as of PHP 7.2.0.
from client.
Thank you for answer. I will think what can i do with it (mbstring.func_overload hardly can effect on it)
And last question: Does exist any way to run your code with mbstring.func_overload = 2?
Thank you!
from client.
Does exist any way to run your code with mbstring.func_overload = 2?
You may try creating a packer which will de-activate this setting while packing/unpacking packets (not tested):
final class MbstringOverloadedPacker implements Packer
{
private $packer;
public function __construct(Packer $packer)
{
$this->packer = $packer;
}
public function pack(Request $request, ?int $sync = null) : string
{
$funcOverload = ini_get('mbstring.func_overload');
ini_set('mbstring.func_overload', 0);
try {
return $this->packer->pack($request, $sync);
} finally {
ini_set('mbstring.func_overload', $funcOverload);
}
}
public function unpack(string $data) : Response
{
$funcOverload = ini_get('mbstring.func_overload');
ini_set('mbstring.func_overload', 0);
try {
return $this->packer->unpack($data);
} finally {
ini_set('mbstring.func_overload', $funcOverload);
}
}
}
And then wrap a regular packer and build a client object from scratch:
$packer = new MbstringOverloadedPacker(new PurePacker());
...
$handler = new DefaultHandler($connection, $packer);
$client = new Client($handler);
$client = $client->withMiddleware(new AuthMiddleware('<username>', '<password>'));
from client.
Hello,
Unfortunatelly, the 'mbstring.func_overload' setting impossible to set in a PHP code.
However, I've found a workaround playing with \mb_internal_encoding('8bit'); for pack\unpack. Also a small change required inside of Greeting class:
$salt = \substr($salt, 0, 20);
replace with
$salt = \mb_substr($salt, 0, 20, '8bit');
And then it start working, anyway partially...
For example:
$result = $client->evaluate('return box.info.memory()');
var_dump($result);
Returns:
array(1) {
[0]=>
array(6) {
["cache"]=>
int(0)
["data"]=>
int(8576)
["tx"]=>
int(0)
["lua"]=>
int(1314007)
["net"]=>
int(933888)
["index"]=>
int(1097728)
}
}
However, the following code:
$result = $client->executeUpdate('
CREATE TABLE users ("id" INTEGER PRIMARY KEY AUTOINCREMENT, "email" VARCHAR(255))
');
var_dump($result);
Throws an error
[Tarantool\Client\Exception\CommunicationFailed]
Unable to read response length. (0)
It happends for me in both cases mbstring.func_overload = 2 and mbstring.func_overload = 0 . Don't you have any thoughts what else should i check?
Thank you!
from client.
It happends for me in both cases mbstring.func_overload = 2 and mbstring.func_overload = 0 . Don't you have any thoughts what else should i check?
Does it work if you execute this query in lua console? Try
docker exec -it <your-tarantool-container-id> sh
tarantoolctl connect 3301
and then follow this tutorial: https://www.tarantool.io/en/doc/2.1/tutorials/sql_tutorial/. Also, you could try to test it on Tarantool 2.1. I could debug it as well, but seems like you've already deleted your repo :)
from client.
Does it work if you execute this query in lua console? Try
It's works without any issues in console. I will try to debug a little bit, maybe i've missed string manupulations without 8bit encoding.
I could debug it as well, but seems like you've already deleted your repo :)
Yes, sorry. It's just for internal use. I'm not sure I can publish it, but at the same time I want to solve issues on our projects.
I will back when I find something.
from client.
Thank you for you help.
It works not with Tarantool 2.1.2, 2.2.0 somehow doesn't work, i'll investigate it later.
At the moment I have last question: Don't you have a plan to add for Tarantool\Client\Connection\StreamConnection option which will handle custom Greeting class\object?
Coz' of "mbstring.func_overload" i should change your original file, i dind't find a way around.
from client.
No, I don't plan to expose the Greeting
class and would strongly recommend you to disable the function overloading as it will break every second library you have installed and will not work with the next versions of PHP anyway.
from client.
Unfortunately, I don't have a choice. CMS which is used on a project has requirement mbstring.func_overload = 2
from client.
Related Issues (20)
- Use Php-client with queue? HOT 3
- possibility to bind params through LUA procedures? HOT 3
- get Space names HOT 4
- executeQuery generates an unknown Request type 11 fatal error HOT 2
- get primary key field names HOT 2
- fetch and return an associative array of datas HOT 2
- Tarantool-php client performances vs pdo/mysql HOT 6
- Unexpected response received: expected sync #974229717, got #429377306. HOT 2
- Multiple insertion of rows in a single transaction HOT 1
- How to connect on remote server HOT 1
- typofix in README.md HOT 1
- "Space 'X' does not exist" exception occurs under load HOT 1
- Return an associative array of data HOT 1
- Bug with select from space with uuid type field by SQL protocol HOT 4
- Require rybakit/msgpack dependency
- Some tests started to fail since Tarantool 2.11.0-entrypoint tag HOT 3
- Non informative trace log of Exceptions HOT 2
- memory leaks with SQL - prepared statements HOT 2
- CI fails due to missing library `libmpdec-dev` for Debian Bookworm
- Why not Symfony/uid ^7 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from client.