klokan / webstor

High performance C++ API for Amazon S3
Apache License 2.0
1 stars 2 forks source link

TileServer on Windows #18

Closed MartinMikita closed 11 years ago

MartinMikita commented 11 years ago

TileServer cannot be compiled on Windows platform.

c:\src\maptiler\net\webstor\pevents.h(10) : fatal error C1083: Cannot open inclu
de file: 'pthread.h': No such file or directory
directory.cpp
net\webstor\directory.cpp(3) : fatal error C1083: Cannot open include file: 'uni
std.h': No such file or directory
pevents.cpp
c:\src\maptiler\net\webstor\pevents.h(10) : fatal error C1083: Cannot open inclu
de file: 'pthread.h': No such file or directory
Generating Code...
c:\src\maptiler\net\webstor\wsconn.cpp(4024) : error C4716: 'webstor::SftpUpload
Request::handleHeader' : must return a value
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\BIN\cl.EXE"' : return code '0x2'
klokan commented 11 years ago

@MartinMikita We may need to port the threading to: https://github.com/klokan/maptiler/blob/master/src/threading.h implemented as: https://github.com/klokan/maptiler/blob/master/src/threading_windows.c https://github.com/klokan/maptiler/blob/master/src/threading_posix.c

xrosecky commented 11 years ago

Header file pevents.h should not be included on compilation on MS Windows, because Windows has native support for multiple events.

MartinMikita commented 11 years ago

Is MAXIMUM_WAIT_OBJECTS really 64? http://stackoverflow.com/questions/5131807/is-maximum-wait-objects-really-64

webstor/sysutils.h or webstor/sysurils.cpp

CASSERT( c_maxEventCount <= MAXIMUM_WAIT_OBJECTS );
enum { c_maxEventCount = 256 };

@xrosecky Can this value be changed into 64?

MartinMikita commented 11 years ago

It was required to install (unzip) the following dependencies on Windows: curl, iconv, xml, openssl (it is using for Qt 4.8.4 x64). It is also needed sqlite3 library for mbtiles.c file

xrosecky commented 11 years ago

@MartinMikita: Yes, you can chage it to 64 on MS Windows.

MartinMikita commented 11 years ago

Finally, I get compilation on Windows. But now, Amazon upload is not working... InvalidAccessKeyId exceptions...

xrosecky commented 11 years ago

Can you disable HTTPS temporary (https://github.com/klokan/webstor/blob/tileserver-maptiler/tileserver.cpp#L48) and use some network sniffer on localhost to capture communication and send me the request with response?

xrosecky commented 11 years ago

Here is an example of captured request:

PUT /webstortest3/upload%2F12%2F770%2F1609%2Epng HTTP/1.0
Host: s3.amazonaws.com
Content-Type: image/png
Date: Wed, 21 Aug 2013 20:41:43 GMT
x-amz-acl: public-read
Authorization:  AWS AKIAIIPTMGH22AZTAB7A:nDTYdyfEO4uyFfFW7YXbyJj2OXk=
Connection: Keep-Alive
Content-Length: 6719

binary content follows

HTTP/1.1 200 OK
x-amz-id-2: nz5ZV3OcOurW8QHEmXAsmV8WeB58GL3trrZ7ay5FXA7ud1+EKBpYE7HuA5uFKPP+
x-amz-request-id: F573443E305582E3
Date: Wed, 21 Aug 2013 20:41:45 GMT
ETag: "b940326431a8ffb6ba2e8ab9fa7a40b6"
Content-Length: 0
Connection: keep-alive
Server: AmazonS3
MartinMikita commented 11 years ago

Start upload in x64 version:

GET /webstortest6/tileserver.json HTTP/1.0
Host: s3.amazonaws.com
Date: Wed, 21 Aug 2013 22:57:43 GMT
Authorization:  AWS 
Connection: Keep-Alive

HTTP/1.1 400 Bad Request
x-amz-request-id: 72B0927FA93358B9
x-amz-id-2: 4KOKk3BZrOKDETDT4EhiD0r42b89gPMoQ7IH64GwfglvcCmDIybzCNWGvhVXR334
Content-Type: application/xml
Date: Wed, 21 Aug 2013 22:57:45 GMT
Connection: close
Server: AmazonS3

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidArgument</Code><Message>Authorization header is invalid -- one and only one ' ' (space) required</Message><ArgumentValue>AWS</ArgumentValue><ArgumentName>Authorization</ArgumentName><RequestId>72B0927FA93358B9</RequestId><HostId>4KOKk3BZrOKDETDT4EhiD0r42b89gPMoQ7IH64GwfglvcCmDIybzCNWGvhVXR334</HostId></Error>

Start upload in x86 version:

GET /webstortest6/tileserver.json HTTP/1.0
Host: s3.amazonaws.com
Date: Wed, 21 Aug 2013 23:09:58 GMT
Authorization:  AWS 9:J8zgkzSnC5eDbDd2/DOjinKiVf8=
Connection: Keep-Alive

HTTP/1.1 403 Forbidden
x-amz-request-id: 09491D8950207C0C
x-amz-id-2: mHoZcXcsMbOm2ZclR1UEISpTOyPDtbwEYlprRwgPX9PlT5k+V5uwPIdc37WYegCy
Content-Type: application/xml
Date: Wed, 21 Aug 2013 23:10:00 GMT
Connection: close
Server: AmazonS3

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidAccessKeyId</Code><Message>The AWS Access Key Id you provided does not exist in our records.</Message><RequestId>09491D8950207C0C</RequestId><HostId>mHoZcXcsMbOm2ZclR1UEISpTOyPDtbwEYlprRwgPX9PlT5k+V5uwPIdc37WYegCy</HostId><AWSAccessKeyId>9</AWSAccessKeyId></Error>
xrosecky commented 11 years ago

Both authorization header are invalid, strange that x86 and x64 differs.

xrosecky commented 11 years ago

Signature is computed here:

https://github.com/klokan/webstor/blob/tileserver-maptiler/webstor/wsconn.cpp#L489

Check if m_accKey and m_secKey in WsConnection class are set correctly.

2013/8/22 MartinMikita notifications@github.com

GET /webstortest6/tileserver.json HTTP/1.0 Host: s3.amazonaws.com Date: Wed, 21 Aug 2013 22:57:43 GMT Authorization: AWS Connection: Keep-Alive

HTTP/1.1 400 Bad Request x-amz-request-id: 72B0927FA93358B9 x-amz-id-2: 4KOKk3BZrOKDETDT4EhiD0r42b89gPMoQ7IH64GwfglvcCmDIybzCNWGvhVXR334 Content-Type: application/xml Date: Wed, 21 Aug 2013 22:57:45 GMT Connection: close Server: AmazonS3

<?xml version="1.0" encoding="UTF-8"?>

InvalidArgumentAuthorization header is invalid -- one and only one ' ' (space) requiredAWSAuthorization72B0927FA93358B94KOKk3BZrOKDETDT4EhiD0r42b89gPMoQ7IH64GwfglvcCmDIybzCNWGvhVXR334

— Reply to this email directly or view it on GitHubhttps://github.com/klokan/webstor/issues/18#issuecomment-23057078 .

MartinMikita commented 11 years ago

I GET IT! IT IS FINALLY WORKING!

klokan commented 11 years ago

Congratulations!

xrosecky commented 11 years ago

Congratulations! Where was the problem? Last commit is seven hours old.

MartinMikita commented 11 years ago

The main problem was with strings .This problem was reflected only on Windows. It is not safe to use the result of std::string.c_str() method as separate variable value. The string should be duplicated. I am not sure why, but I know it happens.

xrosecky commented 11 years ago

Hmm, the accKey and secKey are not modified after constructor call of S3Authentication, so it should be OK according to C++ standard, but maybe MS is of different opinion (http://www.cplusplus.com/reference/string/string/c_str/):

The pointer returned may be invalidated by further calls to other member functions that modify the object.

Thanks for catching this.