1

Here we go, I have a Mojolicious application that works when running on the morbo server. When I run it in IIS it seems to work, but when you submit any form, it's like IIS isn't sure which route is the GET or POST method.

so currently I have routes looking like

my $authorized = $r->under('/conditions_form')->to('Account#is_logged_in');
  $authorized->get('/')->name('beach_conditions_form')->to('form#show_beach_conditions_form');
  $authorized->post('/')->name('submit_conditions')->to('form#submit_beach_conditions');

When my form is completed and submitted it should redirect back to the form like so

$self->redirect_to('beach_conditions_form');

This is when I get my error! The error is along the lines of

The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are "[Wed Jun 28 15:26:22 2017] [debug] Reading configuration file "D:\inetpub\wwwroot\beach_conditions\beach_conditions.conf" [Wed Jun 28 15:26:22 2017] [debug] POST "/conditions_form" [Wed Jun 28 15:26:22 2017] [debug] Routing to controller "BeachConditions::Controller::Account" and action "is_logged_in" [Wed Jun 28 15:26:22 2017] [debug] Routing to controller "BeachConditions::Controller::Form" and action "submit_beach_conditions" [Wed Jun 28 15:26:22 2017] [error] DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert the value NULL into column 'OBS_DT', table 'BeachSafety.dbo.BEACH_CONDITIONS'; column does not allow nulls. INSERT fails. (SQL-23000) [state was 23000 now 01000] [Microsoft][ODBC SQL Server Driver][SQL Server]The statement has been terminated. (SQL-01000) [for Statement "INSERT INTO BEACH_CONDITIONS ( beach_current, flag_color, note, obs_dt, obs_loc, rip_current_risk, water_temp, wave_height, wave_type, weather, wind_direction, wind_speed) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) SELECT SCOPE_IDENTITY()" with ParamValues: 1=undef, 2=undef, 3=undef, 4=undef, 5=undef, 6=undef, 7=undef, 8=undef, 9=undef, 10=undef, 11=undef, 12=undef] 

Which to me, means it just skipped over the GET method and straight to the POST....

If I hard code the path, all is good (but all is not good, because it's hard coded....).

This works..

$self->redirect_to('http://server/beach_conditions/beach_conditions.pl/conditions_form');

I found this, but not much help.

https://groups.google.com/forum/#!topic/mojolicious/IPJopdGCdKQ

Thank you for any information.

gregnnylf94
  • 370
  • 3
  • 16
  • The things your IIS sees are not headers. It's reading the log output, which should go to STDERR and thinks that's the response. How did you connect the Mojo app to IIS? Is it running on hypnotoad through FCGI? It talks about CGI in that message. If that's real CGI it's going to be quite inefficient because it needs to compile the whole application for every request. I don't think you want that. – simbabque Jun 29 '17 at 08:42
  • Ah okay so I'm missing a piece. I am simply running the startup script, like you would in morbo. I had FastCGI turned on but it caused errors, which was strange to me from what I had read. So currently yes I am just running CGI at the moment. I'll have to look into this "hypnotoad". Thank you! – gregnnylf94 Jun 29 '17 at 11:45
  • Okay I'm slightly confused. Hypnotoad is it's on server, like morbo? So you run a server on the server? Seems strange to me, but I'll give it a shot and see what happens. – gregnnylf94 Jun 29 '17 at 11:54
  • Yes, it's the production server. I think you can run it behind iis with FCGI. But maybe also completely without iis. Do you need that specifically? For serving files or something? – simbabque Jun 29 '17 at 12:03
  • That would be okay for my personal use (in fact probably better), but everything my team hosts is on iis. Which means it would have to listen to a different port. I don't think that would be okay. So if there is a way to listen to the same port, I don't see a reason I NEED iis. – gregnnylf94 Jun 29 '17 at 12:08
  • You cannot listen to the same port on the same machine. FCGI will "forward" requests to another port where your app is listening. The idea is to firewall that port from the outside. I'm not very familiar with mojo and have not run anything productively on windows, so I'm a bit out of my element. Maybe there is something in the hypnotoad docs? If that doesn't help, ask in #mojo on irc.perl.org, those guys will figure it out. – simbabque Jun 29 '17 at 12:15
  • Hmm okay, thanks for all the input. Very helpful. – gregnnylf94 Jun 29 '17 at 12:27
  • 1
    Okay so after some research, a proxy server seems to be what I am after. Configure IIS to look at Mojolicious's Daemon server. I'm fairly certain this is the solution. Will be back with the result once I try it. – gregnnylf94 Jun 30 '17 at 11:58

1 Answers1

0

Okay so @simbabque was right, you can host completely indepindent from IIS.

I just made my start up script something like

Mojolicious::Commands->start_app('BeachConditions', 'daemon', '-l', 'http://*:8080');

Now it is accessible and all you do is run the startup script.

This brings me to a new question that I will post. How do you run multiple applications then?

gregnnylf94
  • 370
  • 3
  • 16
  • I think there was no need to delete the other question just now. In fact with the edited title it was a very good alternative to the duplicate. I suggest you undelete it, so others facing the same problem related to Mojo can find it and the duplicate target. :) – simbabque Oct 06 '17 at 16:36